你的“bin”应该是“cucumber” npm 将创建一个指向“node %SCRIPTNAME%”的“cucumber”或“cucumber.cmd”文件。前者用于 posix 环境,后者用于 Windows ......如果你希望“js”成为可执行文件名称的一部分......你应该使用连字符......“cucumber-js”......在您的情况下,拥有 .js 文件将位于 .js.cmd 之前,导致 WScript 解释器将其作为 JScript 文件而不是节点脚本运行。
我建议看一下咖啡脚本的 package.json作为一个很好的例子。
{
"name": "coffee-script",
"description": "Unfancy JavaScript",
"keywords": ["javascript", "language", "coffeescript", "compiler"],
"author": "Jeremy Ashkenas",
"version": "1.4.0",
"licenses": [{
"type": "MIT",
"url": "https://raw.github.com/jashkenas/coffee-script/master/LICENSE"
}],
"engines": {
"node": ">=0.4.0"
},
"directories" : {
"lib" : "./lib/coffee-script"
},
"main" : "./lib/coffee-script/coffee-script",
"bin": {
"coffee": "./bin/coffee",
"cake": "./bin/cake"
},
"scripts": {
"test": "node ./bin/cake test"
},
"homepage": "http://coffeescript.org",
"bugs": "https://github.com/jashkenas/coffee-script/issues",
"repository": {
"type": "git",
"url": "git://github.com/jashkenas/coffee-script.git"
},
"devDependencies": {
"uglify-js": ">=1.0.0",
"jison": ">=0.2.0"
}
}