问题
When I type "npm run test" in the command line, npm goes to package.json, to the "scripts" section and tries to match "test" there. So far so good.
Now, the line behind "test" is the following: "JASMINE_CONFIG_PATH=./spec/support/jasmine.json jasmine-run"
but the first part (everything except "jasmine-run") can be removed witout problems. [I have a similarily structured project where it works, so I can test these modifications]
now: WHERE is npm looking for "jasmine-run" ???
Because since I have a project where the script provided work, I could look for it, but the answer is: in the node_modules folder next to package.json is a module, in whose package.json has, in the "bin" section:
"jasmine-run": "tools/jasmine-run/jasmine-run.js",
However, this exact setup exists in both projects. and in one everything works, while in the other "jasmine-run" cannot be found.
As ana lternative to an answer I'd also take a proper explanation (or source) on how/where npm run actually looks for its stuff, because then I could probably find the error myself.
回答1:
When you run a script with npm like :
npm run-script <name>
or with a shortcut like
npm test or npm start,
your current package directory's bin directory is placed at the front of your path.
For your and in many of the cases will probably be
./node_modules/.bin/
,
which contains a link to your package's executable scripts.
Anyway you have all the explanation how npm runs work here : https://docs.npmjs.com/cli/run-script
回答2:
npm run adds node_modules/.bin to the PATH provided to scripts. Any binaries provided by locally-installed dependencies can be used without the node_modules/.bin prefix.
Check if you can locate jasmine-run inside node_modules/.bin directory.
For reference have a look at this post: https://docs.npmjs.com/cli/run-script
来源:https://stackoverflow.com/questions/52272015/where-is-npm-run-looking-for-the-scripts