I have a folder (a project) with 3 subfolders (client, server, assets). Each subfolder has a different command to start and to work on the project I need to start the 3 apps. This is the folder layout and the commands I use to start each subproject:
- project
- client (ionic serve)
- server (node index)
- assets (http-server -p 8082)
Currently, I go to each of the three folders and start each of the apps. To make the process more standard, each subproject has a package.json with a start script, so I just cd subfolder && npm start
.
My question: is it possible to use npm on the parent folder (i.e., write a package.json
there) in such a way that I can just run the following command and have the same (or similar) effect?
project> npm start
I have tried using the package parallelshell
, but it didnt work (probably because of the cd
:
"scripts": { "start": "parallelshell 'cd app && ionic serve' 'cd api && npm start' 'cd assets && npm start'", }
You should run it in your project root folder, or the folder above your node_modules folder as sometimes the structure can differentiate between projects.
A command line tool for easily making prebuilt binaries for multiple versions of node, electron or node-webkit on a specific platform. NPM.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With