Wednesday, 15 March 2017

ReferenceError: NODE_ENV is not defined with Express

This is my index.js file:

var express = require('express');
var app = express();
var compression = require('compression');
var path = require('path');

app.use(compression());
app.set('port', (process.env.PORT || 9000));

app.use(express.static(path.join(__dirname, 'dist')));
app.use('/public', express.static(path.join(__dirname, '/public')));

app.set('views', __dirname + '/');
app.set('view engine', 'ejs');

app.listen(app.get('port'), function() {
    console.log('Node app is running on port', app.get('port'));
});

and my package.json npm tasks for build and starting the server

"scripts": {
    "start": "NODE_ENV=production node index.js",
    "dev": "NODE_ENV=development webpack-dev-server --progress --bail --open",
    "build": "NODE_ENV=production webpack -p --colors"
},

i don't know how but i still get ReferenceError: NODE_ENV is not defined. Can anyone help?



via Lukas

No comments:

Post a Comment