npm 自定义全局命令
装置node全局命令
一、创立package.json文件,创立命令为 hello
{
"name": "demo",
"version": "1.0.0",
"dependencies": {
},
"bin": {
"hello": "./index.js"
}
}
二、设置文件运行的后果index.js
#!/usr/bin/env node
console.log('hello world')
三、在全局装置 (要 package.json根目录下装置),装置本地的包 到
npm i . -g
四、运行全局命令
hello
发表回复