Nick
Nick

Reputation: 674

NODE_ENV was unexpected at this time error

I am following this tutorial on youtube because i am trying to learn node.js / express.

I changed the following in my package.json file to be able to use nodemon.

package.json

  "scripts": {
    "start": "if [[ $NODE_ENV == 'production' ]]; then node ./bin/www; else nodemon ./bin/www; fi"
  },

However when i run the following command in my cmd prompt I get an error.

set DEBUG=myapp:* & npm start

Error below:

$NODE_ENV was unexpected at this time.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `if [[ $NODE_ENV == 'production' ]]; then node ./bin/www; else nodemon ./bin/www; fi`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I can't seem to figure it out.

Upvotes: 3

Views: 2367

Answers (4)

Sapthaka
Sapthaka

Reputation: 430

If you want to just run nodemon You can do it simply like this

"start" : "nodemon ./bin/www"

and that's all. you're all clear to go

Upvotes: 0

Mohammad Alfaz
Mohammad Alfaz

Reputation: 152

I got the same error but I changed it to :

"scripts": {
   "start": "node ./bin/www",
   "dev": "nodemon ./bin/www"
 },
   

it works for me I'm using "yarn dev" and "npm run dev" for npm.

Upvotes: 1

hsjeevan
hsjeevan

Reputation: 306

I tried installing nodemon globally and it worked.

npm install -g nodemon

"scripts": {
  "start": "node ./bin/www"
}

and used nodemon to start the app

Upvotes: 1

Jahanzaib
Jahanzaib

Reputation: 116

"scripts": { "start": "node ./bin/www" }

now run nodemon or npm start

Upvotes: 0

Related Questions