更新
我刚刚发现我安装了最新的节点代码。我刚刚重新安装了最后一个稳定版本,它似乎对我来说很好。
仅供参考 - 我使用的节点版本 -
Mac-mini:helloworld nimahajan $ npm -v 1.3.11 Mac-mini:helloworld nimahajan $ node -v v0.11.8预
=============================================== ==========
我正在尝试创建一个简单的hello world示例。
在npm install和节点app.js之后,我总是得到以下错误,似乎无法 绕过这个..
jade@0.35.0 express@3.4.0
TypeError: Object #<Object> has no method 'parse'
at detect (/Users/nimahajan/Desktop/Hapus/node/MEAN/MySite/node_modules/jade/node_modules/with/index.js:33:22)
at addWith (/Users/nimahajan/Desktop/Hapus/node/MEAN/MySite/node_modules/jade/node_modules/with/index.js:8:28)
at parse (/Users/nimahajan/Desktop/Hapus/node/MEAN/MySite/node_modules/jade/lib/jade.js:105:11)
at Object.exports.compile (/Users/nimahajan/Desktop/Hapus/node/MEAN/MySite/node_modules/jade/lib/jade.js:142:9)
at Object.exports.render (/Users/nimahajan/Desktop/Hapus/node/MEAN/MySite/node_modules/jade/lib/jade.js:196:15)
at Object.exports.renderFile (/Users/nimahajan/Desktop/Hapus/node/MEAN/MySite/node_modules/jade/lib/jade.js:233:18)
at View.exports.renderFile [as engine] (/Users/nimahajan/Desktop/Hapus/node/MEAN/MySite/node_modules/jade/lib/jade.js:218:21)
at View.render (/Users/nimahajan/Desktop/Hapus/node/MEAN/MySite/node_modules/express/lib/view.js:76:8)
at Function.app.render (/Users/nimahajan/Desktop/Hapus/node/MEAN/MySite/node_modules/express/lib/application.js:506:10)
at ServerResponse.res.render (/Users/nimahajan/Desktop/Hapus/node/MEAN/MySite/node_modules/express/lib/response.js:798:7)
App.js
/*
* Module dependencies
*/
var express = require('express')
, stylus = require('stylus')
, nib = require('nib');
var app = express()
function compile(str, path) {
return stylus(str)
.set('filename', path)
.use(nib())
}
app.set('views', __dirname + '/views')
app.set('view engine', 'jade')
app.use(express.logger('dev'))
app.use(stylus.middleware(
{ src: __dirname + '/public'
, compile: compile
}
))
app.use(express.static(__dirname + '/public'));
app.get('/', function (req, res) {
res.render('index',
{ title : 'Home' }
)
});
app.listen(3000);
的package.json
{
"name": "MySite",
"version": "0.0.1",
"private": "true",
"dependencies": {
"express": "*",
"jade": "*",
"stylus": "*",
"nib": "*"
}
}
我基本上遵循以下示例, http://clock.co.uk/tech-blogs/a-simple-website-in-nodejs-with-express-jade-and-stylus
答案 0 :(得分:0)
我只是尝试使用正常的npm脚手架程序而得到同样的错误。 这可能是一个错误 使用以下包配置:
{
"name" : "todo",
"version" : "0.0.1",
"private" : true,
"dependencies" : {
"jade" : "*",
"connect" : "*",
"express" : "*",
"ejs" : "*",
"mongoose" : "*"
}
}