Tsalikidis Tsalikidis - 1 year ago 122
Node.js Question

Writing command line tool with node

I'm trying to create a command line tool with node (following these instructions).

So I add "bin" to package.json file

"bin": {
"test": "./index.js"

Created index.js file

#!usr/bin/env node

And I use
$ sudo npm link

Finally I try to run it via terminal but I'm getting
-bash: /usr/local/bin/test: usr/bin/env: bad interpreter: No such file or directory

Any ideas anyone?

Answer Source

I don't think npm link is needed in this case; you normally would use it to connect a module from your file system that you might otherwise pull in via the npm install command.

Your shebang syntax looks off to me, though, missing the leading slash:

#!/usr/bin/env node
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download