我检查了两个命令npm start和npm run start,两者完美的作品.我使用了create-react-app.但是为了在CSS模块中进行配置更改,我运行npm eject但是它会引发错误.
但npm run eject有效吗?我很困惑,为什么npm eject不工作.我可以配置吗?
以下是我的package.json:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
Run Code Online (Sandbox Code Playgroud)
AKX*_*AKX 115
npm test,npm start,npm restart,和npm stop都是别名npm run ....
对于scripts您定义的所有其他内容,您需要使用npm run ...语法.
有关更多信息,请参阅https://docs.npmjs.com/cli/run-script上的文档.
Vim*_*ran 18
需要注意的一件有趣的事情是,
如果scripts对象在文件中没有属性,或者从命令行将默认运行。"start"package.jsonnpm startnpm run startnode server.js
但是如果scriptspackage.json中的对象有"start"属性,它会覆盖node server.js并执行属性中的命令"start"。
请参阅 - https://docs.npmjs.com/cli/v7/commands/npm-start#description