Context
I have one main project with several node projects inside it as subdirectories. each of which has its own directories node_modulesand package.jsonfiles. I want to have an npm script defined in my main files package.jsonthat simultaneously run npm scripts from each of these projects.
The code
My directory structure is this:
main:
...
package.json
- sub-project-1
- ...
package.json
- sub-project-2
...
package.json
subproject-1 / package.json:
...
"scripts": {
"start": "node run foo.js"
}
subproject-2 / package.json:
...
"scripts": {
"start": "node run bar.js"
}
The main package .json:
...
"scripts": {
"start": "/* Here I want to do something like npm sub-project-1/ start && npm sub-project-2/ start */
}
Now, obviously, I could copy and paste the commands into a sub-project-1/package.json startscript and sub-project-2/package.jsonstart script in a bash script and run instead. But I want to change these scripts npm startwithout having to manually change the bash script every time. Is there any way to do this?