创建快速项目首次运行会​​产生错误

时间:2013-04-06 23:09:31

标签: node.js express

我在全球安装了快递。

我创建了一个名为helloExpress的新项目,如下所示:

express helloExpress -c less

安装所有依赖项:

cd helloExpress
sudo npm install

运行应用程序:

node app.js

输出错误:

/home/dev/projects/helloExpress/app.js:1
s., */,,var expr
      ^

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)

查看app.js的代码,它看起来像这样:

/**, * 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);undefined  app.use(require('less-middleware')({ src: __dirname + '/public' }));,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'));,});,

正如你所看到的,无处不在。 这是一个已知的错误还是我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

正如Jonathan Lonowski在评论中所说,我使用的Node.js版本太旧了。

我按照本教程安装了较新版本的Node.js:http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/