我尝试运行这个简单的代码但是找不到想要的输出。
var express = require('express'),
app = express(),
path = require('path')
cookieParser = require('cookie-parser')
session = require('express-session');
app.set('views', path.join(__dirname , 'views'));
app.use(express.static(path.join(__dirname,'public')));
var env = process.env.NODE_ENV || 'development';
if(env === 'development'){
// dev specific settings
} else {
//Production specific settings
}
require('./routes/routes.js')(express,app);
app.listen (3000 , function(){
console.log('Mode:'+ env);
});
RUN ON Window CMD:>设置NODE_ENV =开发
节点app.js
> Mode : development
但是 -
RUN ON Window CMD:>设置NODE_ENV =生产
节点app.js
> Mode : development // again same thing
答案 0 :(得分:1)
删除等号NODE_ENV=production node app.js
周围的空格或尝试运行此代码main()
答案 1 :(得分:0)
尝试此操作使用控制台日志验证输出。 删除等号符号集NODE_ENV = production周围的空格 或者尝试像这样的NODE_ENV =生产节点app.js
运行代码var express = require('express'),
app = express(),
path = require('path')
cookieParser = require('cookie-parser')
session = require('express-session');
app.set('views', path.join(__dirname , 'views'));
app.use(express.static(path.join(__dirname,'public')));
var env = process.env.NODE_ENV || 'development';
if(env == 'development'){
// dev specific settings
console.log("Development");
} else {
//Production specific settings
conosole.log("Production");
}
require('./routes/routes.js')(express,app);
app.listen (3000 , function(){
console.log('Mode:'+ env);
});