I have created a npm package that has 2 scripts that can be run from the command line:
"bin": {
"script1": "./dist/script1.mjs",
"script2": "./dist/script2.mjs",
},
Both scripts have the shebang line on top of the file #!/usr/bin/env node
When I run:
npm i -g mypackage
Then I can call: script1
which works fine.
But when I run npm exec -- mypackage "-p" "script1"
or npx mypackage script1
it fails with: Error: could not determine executable to run
14 verbose stack at getBinFromManifest (/Users/marcelh/.nvm/versions/node/v20.10.0/lib/node_modules/npm/node_modules/libnpmexec/lib/get-bin-from-manifest.js:17:23)
14 verbose stack at exec (/Users/me/.nvm/versions/node/v20.10.0/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js:198:15)
14 verbose stack at async Npm.exec (/Users/me/.nvm/versions/node/v20.10.0/lib/node_modules/npm/lib/npm.js:207:9)
14 verbose stack at async module.exports (/Users/me/.nvm/versions/node/v20.10.0/lib/node_modules/npm/lib/cli/entry.js:74:5)
15 verbose pkgid [email protected]
16 error could not determine executable to run```
What could be the problem here?