2

我是 Node.js 的新手,想用 Express 创建一个简单的应用程序。

npm install -g express
npm install -g ejs

express test -t ejs
cd test/
npm install

现在我有一个应用程序框架。但它坏了。例如我的 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);,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'));,});,

在“节点应用程序”之后,它抛出

C:\Users\saxon\Downloads\123\test\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:31)
    at Function._load (module.js:308:12)
    at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:40)
4

1 回答 1

2

问题解决:我安装的版本是0.6.xxx,现在是0.10.xxx重新安装所有包(ejs,express,connect,request)

于 2013-04-10T10:06:53.603 回答