node开发命令行脚本 / commander

1. 脚本第一行添加 #!/usr/bin/env node

// index.js
#!/usr/bin/env node
console.log('hello world')

2. package.json 添加bin

{
  "name": "hello-test",
  "version": "1.0.0",
  "bin":{
   "hello-cli":"index.js"
  }
}

3. npm link

node开发命令行脚本
https://www.cnblogs.com/lcosima/p/11482428.html

posted @ 2021-08-02 08:54  彭成刚  阅读(87)  评论(0编辑  收藏  举报