Reputation: 9095
I am able to run both the npm start
and npm run start
commands. I used create-react-app to create my application. To make configuration changes in the CSS module, I want to run npm eject
but it throws an error.
The npm run eject
command works however. I'm confused as to why npm eject
did not work. Can I configure it to work?
Below is my package.json
file:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
Upvotes: 270
Views: 192404
Reputation: 1
Some commands are recognized by npm by default to simplify certain tasks. Just like "npm start,npm test,npm stop,npm restart", as noted by @AKX.
These commands are directly recognized by npm, that's why we don't need to use the npm run
prefix.
However, for other commands like build
, we need to use npm run build
, because build
is not directly recognized by npm and is considered a user-defined script.
If you want to examine this topic: https://docs.npmjs.com/cli/v7/using-npm/scripts
Upvotes: 0
Reputation: 187
Telling this because sometimes this can be help to someone.
Inside the jenkins pipelines you should use npm commands with "run"
ex- npm run start
if not the command will not be executed.
Upvotes: 5
Reputation: 755
One interesting thing to note is,
If the scripts
object does not have a "start"
property in package.json
file, npm start
or npm run start
from command line will run node server.js
by default.
But if the scripts
object in package.json has "start"
property, it overrides node server.js
and executes the command in "start"
property.
See - https://docs.npmjs.com/cli/v7/commands/npm-start#description
Upvotes: 21
Reputation: 928
npm start
is the short form for npm run start
. So, its one and the same thing.
Upvotes: 40
Reputation: 168967
npm test
, npm start
, npm restart
, and npm stop
are all aliases for npm run xxx.
For all other scripts
you define, you need to use the npm run xxx
syntax.
See the docs at https://docs.npmjs.com/cli/run-script for more information.
Upvotes: 481