您好,我试图一起使用jade
和express
。但它给了我TypeError
。
我制作了npm init
,npm install express -save
,然后是node app.js
。但它给了我同样的错误"TypeError: express is not a function"
// Module dependencies
var express = require('express')
, nib = require('nib')
, mysql = require('mysql')
var app = express();
var app = module.exports = app.createServer();
app.set('views', __dirname + '/views')
app.set('view engine', 'jade')
app.use(express.logger('dev'))
package.json
:
{
"name": "reddit-node-mysql",
"description": "A demo of how to use Express and MySQL together",
"author": "Clarence Leung <github@clarle>",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "^2.5.11",
"mysql": "~2.0",
"nib": "^1.1.2",
"jade": "^1.0.4"
},
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "ISC",
"devDependencies": {}
}
解决方案 我的模块&#39;版本已过时,因此无法正常安装。我更新了它们的版本,现在正在工作。
答案 0 :(得分:2)
您使用的是过时的快递,
移除
来自json包的"express": "^2.5.11",
并运行
npm install --save express