How to execute two listening commands at the same time with npm

Starting a project in a day-to-day project requires more than one command to start a project

This is very troublesome to open two bash very troublesome finally found a better solution

For example mine:

npm run dev //Start the project project

npm run json //Start 3003 port simulation backend

In Baidu, I saw that some people can use splicing to achieve

"mock_server": "json-server mock/db.json --port 3003 &",
"server": "node server.js &",
"start": "npm run mock_server && npm run server" 

I experimented and found that only one command can be started.

Use the concurrent module to monitor and execute two commands at the same time

npm install concurrently --save

Then "start" in "script" in package.json

"start": "concurrently \"npm run json\" \"npm run dev\"",

In this way, it is possible to monitor and execute two commands at the same time.

Welcome to check out the various issues I summarized in the text on my github, I believe you will get inspired boold

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326369374&siteId=291194637