,/**, * Module dependencies., */,,var express = require('express'), , routes = require('./routes'), , user = require('./routes/user'), , http = require('http'), , path = require('path');,,var app = express();,,// all environments,app.set('port', process.env.PORT || 3000);,app.set('views', __dirname + '/views');,app.set('view engine', 'jade');,app.use(express.favicon());,app.use(express.logger('dev'));,app.use(express.bodyParser());,app.use(express.methodOverride());,app.use(app.router);,app.use(express.static(path.join(__dirname, 'public')));,,// development only,if ('development' == app.get('env')) {, app.use(express.errorHandler());,},,app.get('/', routes.index);,app.get('/users', user.list);,,http.createServer(app).listen(app.get('port'), function(){, console.log('Express server listening on port ' + app.get('port'));,});,
中间缩进被替换成了两个空格。执行 node app.js
时
/home/other/microblog/app.js:1
,/**, * Module d
^
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
SyntaxError: Unexpected token ,
at Module._compile (module.js:429:25)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:41)
10 回复
对啊。正常来说,语句不应该是这样的格式啊。
/*** Module dependencies. */
var express = require('express'),
routes = require('./routes'),
user = require('./routes/user'),
http = require('http'),
path = require('path');
var app = express();
// all environments,app.set('port', process.env.PORT || 3000);
…应该是这样的格式才对吧。。。 不知道是安装出了问题,还是哪里的问题。