无法在 npm 中同时运行两个脚本
我正在尝试从根目录运行我的全栈应用程序中的两个脚本。根目录具有以下结构: 。/客户 。/服务器 ./package.json(应该同时运行客户端和服务器)。客户端和服务器有自己的 package.json 文件,其中有给定的脚本来运行每个文件。
在我的根 package.json 中,我有以下命令:
"scripts": {
"server":"npm run dev --prefix server",
"client": "npm start --prefix client",
"watch": "npm run server & npm run client"
但只有服务器正在运行。无法使用此命令运行客户端
I'm trying to run two scripts in my fullstack app from root directory. Root directory has following structure:
./client
./server
./package.json (which is supposed to run both client and server). Client and server has their own package.json files where there is given scripts to run each.
In my root package.json I have following command:
"scripts": {
"server":"npm run dev --prefix server",
"client": "npm start --prefix client",
"watch": "npm run server & npm run client"
But only server is running. Can't run the client with this command
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚解决了这个问题。原因是使用与号 (&) 同时运行两个脚本在 Windows shell 中不起作用。所以我必须使用
npm config set script-shell bash
将默认 shell 更改为 bash shellI just solved the problem. The reason was running two scripts simultaneously with ampersand (&) does not work in windows shell. So I had to change my default shell to bash shell with
npm config set script-shell bash