How can I run multiple npm scripts in parallel?

后端 未结 22 2472
灰色年华
灰色年华 2020-11-22 05:48

In my package.json I have these two scripts:

  \"scripts\": {
    \"start-watch\": \"nodemon run-babel index.js\",
    \"wp-server\": \"webpack-         


        
22条回答
  •  没有蜡笔的小新
    2020-11-22 06:18

    This worked for me

    {
    "start-express": "tsc && nodemon dist/server/server.js",
    "start-react": "react-scripts start",
    "start-both": "npm -p -r run start-react && -p -r npm run start-express"
    }
    

    Both client and server are written in typescript.

    The React app is created with create-react-app with the typescript template and is in the default src directory.

    Express is in the server directory and the entry file is server.js

    typescript code and transpiled into js and is put in the dist directory .

    checkout my project for more info: https://github.com/nickjohngray/staticbackeditor

    UPDATE: calling npm run dev, to start things off

    {"server": "tsc-watch --onSuccess \"node ./dist/server/index.js\"",
    "start-server-dev": "npm run build-server-dev && node src/server/index.js",
    "client": "webpack-dev-server --mode development --devtool inline-source-map --hot",
    "dev": "concurrently \"npm run build-server-dev\"  \"npm run server\" \"npm run client\""}
    

提交回复
热议问题