8
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "server": "nodemon backend/server.js",
    "client": "npm start --prefix frontend",
    "dev": "concurrently \"npm run server\" \"npm run client\""
  }

here's my scripts for the package.json file that's outside the frontend and backend folders (in the root folder). and when I run the command npm run dev it doesn't work for some reason. note that npm run server and npm run client work prefectly but the issue is when I run the command npm run dev which has the concurrently in it, I don't know what's the issue, is there something I can do to fix this? here's the error message that I get:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ecommerce_shop@1.0.0 dev: `concurrently "npm run server" "npm run client"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ecommerce_shop@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2021-01-29T18_24_43_756Z-debug.log

Pengin
  • 534
  • 12
  • Did you try running the command from the terminal? also try running it this way `npm run server && npm run client` – programmer Jan 29 '21 at 18:40
  • as I mentioned both ```npm run server``` and ```npm run client``` work just fine when executed separately, but when I run the ```npm run dev``` (which contains the ```concurrently```) it doesn't work, So I guess there must be a problem with ```concurrently``` right? – Pengin Jan 29 '21 at 18:47
  • I'm not sure what `concurrently` does I assume it runs both simultaneously, now if client is dependent on the server that might cause the issue. – programmer Jan 29 '21 at 18:53
  • Is there anything in the log file listed that exposes a more specific error? It’s possible if your client depends on the server to start that it is just exiting immediately if it happens to start before the server. – Todd Rylaarsdam Jan 29 '21 at 18:54
  • well if I don't run the server, the client still launches but fails to fetch data – Pengin Jan 29 '21 at 18:55
  • @ToddRylaarsdam well, I tried, but still got the same error. I think the problem is with concurrently or npm but don't know what it is. I use the same scripts for my other projects but they work just fine, I don't know what I'm doing wrong now. – Pengin Jan 29 '21 at 18:58

1 Answers1

0

Usually, npm ELIFECYCLE error means that your npm project installation is corrupted.

Try the following, taken from this other SO question:

  1. Run npm cache clean --force or
  2. delete node_modules folder
  3. delete package-lock.json file
  4. npm install

Also to make sure you are using concurrently from your local installation and not your global one, I suggest appending npx to it:

    "dev": "npx concurrently \"npm run server\" \"npm run client\""
tmilar
  • 736
  • 5
  • 13