json
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
- 在 React 项目中,可以执行
npm start命令,但是,无法执行npm build命令
问题原因
- NPM 对一些常用命令提供了简写
| 完整命令 | 简写 |
|---|---|
npm run start |
npm start |
npm run test |
npm test |
npm run stop |
npm stop |
npm run restart |
npm restart |
npm run build |
没有简写 |
-
start、test、stop、restart被视为生命周期脚本,这些命令在 NPM 生态中有特殊含义 -
build不是标准的生命周期脚本,所以必须使用npm run build