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
console.log('test');
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?
npm link
links the module locally. For your bin, it means that the binary is installed into node_modules/.bin/
(if i recall fine).
To link a package globally, you should use the --local
arg.
npm link . --local
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.