我正在用nodeJS编写CLI脚本
hello world脚本有效,但是当我尝试直接在CLI上调用时,
$ npm链接
它显示:
zsh:找不到命令:shutalo
package.json:
{
"name": "screen_shooter",
"version": "1.0.0",
"private": true,
"description": "",
"main": "index.js",
"directories": {
"lib": "lib",
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\"
&& exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"bin": {
"shutalo": "./index.js"
}
}
index.js:
#!/usr/bin/env node
'use strict'
// The rest of the code will be here...
console.log("Hello mako!")
因此,如果我执行$ node index.js,我会得到预期的“你好”
但如果我这样做 $ shutalo我得到
zsh:找不到命令:shutalo
那么,使“ shutalo”呼叫有效的原因是什么?谢谢