Is it possible to use npm to run scripts in multiple subfolders?

it is really late to answer but you got built-in option --prefix, example:

-package.json
-/dist/ssr/package.json
# package.json in root
npm run start --prefix dist/ssr

You can use "concurrently" to accomplish this. So you would create a package.json which looks something like the following:

...
"scripts": {
  "client": "cd client && npm start",
  "server": "cd server && npm start",
  "assets": "cd assets && ionic serve",
  "start": "concurrently \"npm run client\" \"npm run server\" \"npm run assets\" ",
},
...
"devDependencies": {
  "concurrently": "^1.0.0"
}
...

Note: This will start all three processes concurrently which means that you get mixed Output of all three (like topheman already mentioned)


The problem is that all your three scripts are server launching-like script task, which means that they're not like a build task (for example) that runs for 10s and stop the process.

For each one of them, you launch them, and the process continues indefinitly.

You could launch all of them in a daemon way with something like forever, but in your case, you are in dev mode (so you want all the logs, and you don't want the errors from the nodejs server mixed with the ionic one ...).

In case you don't mind about mixing logs: https://www.npmjs.com/package/forever (I assume this does nearly the same thing as parallelshell ...)

Tags:

Npm