0

We currently have a project with a server folder and a client folder.

To run the project we have to cd to server folder, type npm run nodemon then, in a new Terminal tab/window, switch to the client folder and run npm run proxy.

The second command is a script in package.json: "proxy": "ng serve --sourcemap --extractCss -o --hmr -e=hmr --proxy-config proxy.config.json",

So, how do I create one script in package.json to do both? I realize how to run scripts in parallel, but the odd part here is the 2 scripts in different directories. And different terminal windows.

Steve
  • 14,401
  • 35
  • 125
  • 230
  • 1
    Possible duplicate of [How can I run multiple NPM scripts in parallel?](https://stackoverflow.com/questions/30950032/how-can-i-run-multiple-npm-scripts-in-parallel) – Estus Flask Sep 20 '17 at 18:07
  • that doesn't really deal with running in different folders. perhaps i should run a script a the root? – Steve Sep 20 '17 at 18:13
  • There are probably questions that suit the case better. E.g. https://stackoverflow.com/a/35893546/3731501 . And yes, if `server` and `client` are siblings, it's a good thing to set up a separate project on their parent folder. – Estus Flask Sep 20 '17 at 18:19

1 Answers1

1

Try with this script command and let me know its working:

"scripts": {
       "proxy": "(cd ../path/to/server && npm run nodemon) && (ng serve --sourcemap --extractCss -o --hmr -e=hmr --proxy-config proxy.config.json)",    
    }
kgangadhar
  • 4,886
  • 5
  • 36
  • 54
  • currently, there's no package.json at the root. the main package.json with the scripts and node modules is in `/client`. But, yes, `/client` and `/server` are siblings in the root folder. – Steve Sep 20 '17 at 18:17
  • that starts the server, but then it seems the second command does not run. `(cd ../server && npm run nodemon) && (ng serve --sourcemap --extractCss -o --hmr -e=hmr --proxy-config proxy.config.json)` – Steve Sep 20 '17 at 18:23
  • `|` replaced command working without any problem, by starting both the server? – kgangadhar Sep 20 '17 at 18:30
  • Apparently. The browser opens, running the project. – Steve Sep 20 '17 at 18:33