I have checked both commands npm start and npm run start, both works perfectly. I used create-react-app. But to make configuration changes in the CSS module, I run npm eject but it throws an error.

But npm run eject worked? I'm confused on why npm eject didn't work. Can I configure this?

Below is my package.json:

  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }

Learner

Ответов: 3

Ответы (3)

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.

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

npm startэто краткая форма для npm run start. Так что это одно и то же.

2022 WebDevInsider