'Where is npm run looking for the scripts?
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.
Solution 1:[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
Solution 2:[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
Solution 3:[3]
In case anyone else ends up here looking for the answer after running create-react-app, here is where I found them.
The line from package.json
is
"start": "react-scripts start"
In VSCode, open the node_modules
and scroll down to react-scripts
.
Then open up 'scripts', and there they are.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tiago Neiva |
Solution 2 | Ashish |
Solution 3 | Tyler2P |