我试图将另一条命令附加到 yarn start
. 我不知道这是否可能,但当我运行命令 yarn start
我想让我的react应用启动,同时也想启动我的服务器。
我所知道的是使用2个终端,其中一个是react应用的目录,然后调用到 yarn start
C:\Users\ivanr\Documents\GitHub\bees\business-scheduler>
和一个服务器目录(在react app目录内),然后调用在 node src/index.js
C:\Users\ivanr\Documents\GitHub\bees\business-scheduler\server>
"scripts": {
"start": "react-scripts start", // is it possible that I can say in server directory run node src/index.js here?
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
你可以使用 同时
首先安装
$ npm install concurrently
然后在你的命令中使用它
"scripts": {
"start": "concurrently \"yarn start-client\" \"yarn start-server\"",
"start-client": "react-scripts start",
"start-server": "cd .\server && node src/index.js"
}
您可以使用 npm-run-all
"scripts": {
"clean": "rimraf dist",
"lint": "eslint src",
"build": "babel src -o lib"
}
npm-run-all clean lint build