0

我使用 Windows 10、node 5.3.0 和 npm 3.5.2 我做了一个 cli,一个简单的 hello world。这是它的模块包

{
"name": "helloworld",
"version": "1.0.0",
"bin": {"hellow": "hello.js"},
"preferGlobal": true,
"description": "Hello...",
"main": "hello.js",
"scripts": {
"test": "node hello.js"
},
"keywords": [
"testing"
],
"author": "me",
"license": "ISC"
}

测试工作正常,我从其目录安装模块

npm install -g helloworld 当我执行“hellow”时,会出现它的路径,Windows 会询问我如何打开文件。npm 包装器是这样的,来自 node_modules 目录

"%~dp0\node_modules\helloworld\hello.js" %*

我不知道出了什么问题。谢谢。

4

1 回答 1

0

好的,我解决了它做更多的调查

这是一个关于如何制作完整 npm 包的很好的指南http://www.anupshinde.com/posts/how-to-create-nodejs-npm-package/

除了你需要在 bin 脚本的开头添加这一行

#!/usr/bin/env node

所以,这已经完成了(我很高兴=))

于 2016-01-01T14:14:52.150 回答