Wednesday, February 21, 2018

npm run start-all

This command runs all of the servers that could be run from the same folder with this trick.

 
 

Addendum 2/22/2018: What is above isn't true at all. start-all is just in the scripts in a package.json I am looking at and to run two server instantiation files at once it in turn defers to:

concurrently "foo.js" "bar.js"

 
 

Create scripts you can run from the folder containing package.json (the topmost folder for your app also holding the node_modules folder) via the command prompt with Node.js at package.json itself like so:

{
   "name": "whatever",
   "version": "1.0.0",
   "description": "whatever",
   "main": "foo.js",
   "scripts": {
      "start-foo": "node foo.js",
      "start-bar": "node bar.js",
      "start-all": "concurrently \"node foo.js\" \"node bar.js\""
   },
   "author": "",
   "license": "ISC",
   "dependencies": {
      "body-parser": "^1.18.2",
      "concurrently": "^3.5.1",
      "eslint": "^4.15.0",
      "express": "^4.16.2",
      "json-server": "^0.12.1",
      "nodemon": "^1.13.3"
   }
}

 
 

The ISC License (the Open Source Initiative license) is this. ISC stands for Internet Systems Consortium, a non-profit for internet infrastructure and vaguely making the world a better place.

No comments:

Post a Comment