B
B
bormor2018-07-12 08:22:18
Node.js
bormor, 2018-07-12 08:22:18

How to run json-server and React/vue at the same time by npm start?

Head-on option doesn't work (using VueJS as an example)

"scripts": {
    "start": "npm run dev & npm run rest-api",
    "dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
    "build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
    "rest-api": "json-server --watch server/api/db.json"
  },

Vue starts up and starts tracking changes. The queue does not reach json-server.
How can I get npm start to start both the json-server and build the frontend on Vue / React at the same time?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim, 2018-07-12
@bormor

First three google links:
1) npm-run-all
package 2) npm-run-parallel
package 3) so question and fourth package ( https://github.com/kimmobrunfeldt/concurrently - I would start with it)
search engine query: npm run parallel scripts

A
Anton Shvets, 2018-07-12
@Xuxicheta

npm run rest-api &; npm run dev
What packages, my God .....

D
Dark_Scorpion, 2018-09-28
@Dark_Scorpion

The pm2 module for launching various applications and the ability to create clusters.
It is possible through the command line separately, it is possible simultaneously through the pm2.config.js file:

module.exports = {
  apps : [{
    name        : "worker",
    script      : "./worker.js",
  }, {
    name       : "api-app",
    script     : "./api.js",
  }]
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question