I am trying to publish npm package, when i am install the package globally and try to run the cli command i get this errors:
/.nvm/versions/node/v0.12.2/bin/myPack: line 1: use strict: command not found /.nvm/versions/node/v0.12.2/bin/myPack: line 3: syntax error near unexpected token `(' /.nvm/versions/node/v0.12.2/bin/myPack: line 3: `var _commandLineArgs = require('command-line-args');'
The top of the file that the error refer to:
'use strict'; var _commandLineArgs = require('command-line-args'); var _commandLineArgs2 = _interopRequireDefault(_commandLineArgs);
The package.json bin section:
"bin": { "myPack": "dist/myPack.js" }
When i am running this in my local development this works well, what is the problem?
Your script should start with a shebang line, otherwise it will be executed as a shell script (hence the errors).
Add this as first line to dist/myPack.js
:
#!/usr/bin/env node
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With