0

I have the following scripts property in package.json:

"scripts": {
    "start": "webpack -w && nodemon server.js",
    "watch:server": "nodemon server.js",
    "watch:build": "webpack -w",
},

When I run npm run start it only starts the webpack -w command but not the nodemon server.js command. I thought having && will run the scripts sequentially but it is definitely not the case for me. I have seen many people chaining execution with && and it works fine.

Why is mine not working?

Lawrence Cherone
  • 46,049
  • 7
  • 62
  • 106
kabison33
  • 101
  • 2
  • 10

1 Answers1

0

If webpack -w is not finishing successfully, your second command nodemon server.js won't run. Using a single & should allow the second one to run even if the first one fails.

The Otterlord
  • 1,680
  • 10
  • 20
  • But I want to run `nodemon` after `webpack` hence the `&&`. And I am pretty sure that `webpack` finished successfully.. Its just that `nodemon` won't run after it. – kabison33 Aug 14 '20 at 20:19
  • Not sure why `&&` would not work unless `webpack` is exiting with an error. If you don't care whether or not it succesfully exits my answer should work fine. Please see this answer if you want more info: https://stackoverflow.com/a/8055390/14104186 – The Otterlord Aug 15 '20 at 09:10