我正在努力扩展开源raml2html
库,它使用raml契约来生成html文档。主要事实:
该库在bin/raml2html
文件中放置了二进制;在package.json
中陈述了如下:
"bin": {
"raml2html": "./bin/raml2html"
}
当用户npm install
时,程序执行
./bin/raml2html examples/example.raml -o examples/example.html
和 git bash 的二进制文件,它运行正常。但是,我想将这些命令包装为npm run script,所以我定义:
"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
或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以在同一个包中使用二进制文件?