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"
}
}
2023-12-23 20:30:27
#!/usr/bin/env node
// index.js
#!/usr/bin/env node
console.log(‘hello world‘)
{
"name": "hello-test",
"version": "1.0.0",
"bin":{
"hello-cli":"index.js"
}
}