[英]Run 2 npm commands at once
I made a MERN project, and my structure is one backend folder and one frontend folder.我做了一个 MERN 项目,我的结构是一个后端文件夹和一个前端文件夹。
So, every time I work on it I have to cd
to backend , run npm start , then in another tab, go to frontend and run npm start .因此,每次我处理它时,我都必须
cd
到后端,运行npm start ,然后在另一个选项卡中,转到前端并运行npm start 。
Is it possible to do a npm init in the root folder, and create a npm start that will run both commands at once ?是否可以在根文件夹中执行npm init并创建一个同时运行两个命令的npm start ?
I'm new to terminal.我是终端的新手。
Thanks !谢谢 !
There are several ways you can do :有几种方法可以做到:
1- You can use concurrently(npm install -g concurrently) 1- 您可以同时使用(同时使用 npm install -g)
---> concurrently "command1 arg" "command2 arg
" --->
concurrently "command1 arg" "command2 arg
”
the most developer use these ways.And i know just these ways.大多数开发人员使用这些方式。我只知道这些方式。
You can use this command in your terminal :您可以在终端中使用此命令:
node frontend/index.js & node backend/index.js
or要么
npm start --prefix frontend/ & npm start --prefix backend/
You may have different paths to your files您的文件可能有不同的路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.