Run JSR library from NPX
I have built a package that uses Deno internals at https://jsr.io/@aminnairi/tsconfig@0.2.0 but I'm having issues run this package from NPX as per the documentation.
Using the
npx jsr run @aminnairi/tsconfig
command does not work, same thing when used with npx jsr run jsr:@aminnairi/tsconfig
.
Am I missing something? The command deno run -A jsr:@aminnairi/tsconfig
works though.4 Replies
Looks like Node doesn't support
import.meta.main
https://github.com/nodejs/node/issues/49440 . Also this SO question is related https://stackoverflow.com/questions/45136831/node-js-require-main-moduleThank you for your insights. I've updated my code and I'll try that then report here.
Is it just me or has the
jsr
package been removed from npm
?
Looks like there is a 404 when trying to access the documentation
Or woaw, looks like we are on the verge of an intl outage ! No package to be found on npmjs.com nor their servers
Looks like a maintenance of their servers went wrong I guess 🤷♂️
After everything returned normal and testing the following command (prior to removing the import meta main) I still get this error
Tested in a Docker environment with the following
Looks like there is a similar issue using BunI see. Looks like the
jsr run
command invokes the active package manager's script
feature. It doesn't run the package you pass to it https://github.com/jsr-io/jsr-npm/blob/52f93c31b00661a6cf2ba40a9663e02e5b199506/src/commands.ts#L194-L201 . I guess a workaround would be to import the package in a local file and run that fileOh I understand, right. Thank you for the permalink!
Should I open an issue or is it the expected behavior when using Deno and
npx jsr
?
Yeah, as I dig deeper, I saw that Deno, behind the scenes, transpiles the file to an index.js
file that can be used to execute the command manually, but it looks cumbersome to do.
I'll stick to Deno for now, thank you for your time!