3

I'm working on extending open source raml2html library, which consumes raml contract to generate html docs. Key facts:

  • the library has a binary placed in bin/raml2html file; th ebinary is stated in package.json as follows:

    "bin": { "raml2html": "./bin/raml2html" }

    when npm install'ed by the users, the program is executed

  • I use the binary to update examples: both source .raml files and output .html files are kept in the repo. I'm using the binary with ./bin/raml2html examples/example.raml -o examples/example.html with git bash under windows and it works fine.
  • however, I want to wrap this commands as npm run script, so I define:

    "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" },

    and when I call either npm run examples or npm run examples:example, both fail the same way:

`

$ 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

It says that '.' is not recognized as an internal or external command - well, that's true, ./bin/raml2html is not how I should do that on windows. But it's being ran under node.js/npm layer and package.json:bin can understand this syntax. I get confused with that.

The question is: how can I set up npm run scrpt to use the binary inside the same package?

ducin
  • 25,621
  • 41
  • 157
  • 256

0 Answers0