Why My server is not running using the npm run start:prod ? Below is packgae.json file

Viewed 1222

When I try to run in the production mode, then I got the below error:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! shop-api@1.0.0 start:prod: `NODE_ENV=production nodemon server.js`
npm ERR! Exit status 1
{
  "name": "shop-api",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "start:dev": "nodemon server.js",
    "start:prod": "NODE_ENV=production nodemon server.js",
    "debug": "ndb server.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.19.0",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "mongoose": "^5.9.6",
    "morgan": "^1.10.0",
    "ndb": "^1.1.5"
  },
  "devDependencies": {
    "nodemon": "^2.0.2"
  }
}
4 Answers

I ran into the same problem. Just do this:

"start": "nodemon server.js",
"start:prod": "NODE_ENV=production npm start"

After adding "start:prod": "SET NODE_ENV=production && nodemon server.js" in package.json instead of "start:prod": "NODE_ENV=production nodemon server.js".Then my code is running

I ran into same issue. this will solve it for you

"start:prod": "SET NODE_ENV=production && nodemon server.js"

I experience the same problem, just run this command

//=> npm start prod this work for me 100%

here is my package.json file

"start": "nodemon server.js",
"start:prod": "NODE_ENV=production nodemon server.js",
Related