我正在扩展开源raml2html
库,它使用 raml 合同来生成 html 文档。关键事实:
该库有一个二进制文件放在
bin/raml2html
文件中;二进制文件说明package.json
如下:"bin": { "raml2html": "./bin/raml2html" }
当
npm install
用户 'ed 时,程序被执行- 我使用二进制文件来更新示例:源 .raml 文件和输出 .html 文件都保存在 repo 中。我在 Windows 下使用
./bin/raml2html examples/example.raml -o examples/example.html
带有git bash的二进制文件,它工作正常。 但是,我想将此命令包装为 npm run 脚本,因此我定义:
"scripts": { ... "examples:example": "./bin/raml2html examples/example.raml -o examples/example.html", "examples:github": "./bin/raml2html examples/github.raml -o examples/github.html", "examples": "npm run examples:example && examples:github" },
当我调用
npm run examples
or时npm run examples:example
,两者都以同样的方式失败:
`
$ npm run examples:example
> raml2html@2.4.0 examples:example C:\Users\tomasz.ducin\Development\GitHub\raml2html
> ./bin/raml2html examples/example.raml -o examples/example.html
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "examples:example"
npm ERR! node v4.4.3
npm ERR! npm v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! raml2html@2.4.0 examples:example: `./bin/raml2html examples/example.raml -o examples/example.html`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the raml2html@2.4.0 examples:example script './bin/raml2html examples/example.raml -o examples/example.html'.
npm ERR! This is most likely a problem with the raml2html package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./bin/raml2html examples/example.raml -o examples/example.html
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs raml2html
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls raml2html
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\tomasz.ducin\Development\GitHub\raml2html\npm-debug.log
它说'.' is not recognized as an internal or external command
- 嗯,这是真的,./bin/raml2html
不是我应该在 Windows 上这样做。但它是在 node.js/npm 层下运行的,并且 package.json:bin 可以理解这种语法。我对此感到困惑。
问题是:如何设置 npm run scrpt 以使用同一包中的二进制文件?