为什么找不到模块'玉'

时间:2015-09-21 18:12:05

标签: javascript node.js express

我正在使用带有Express 4.13.3的node.js

当我运行我的文件时,我一直得到错误说

Error: Cannot find module 'jade'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at new View (/Users/alatebloomer/node_modules/express/lib/view.js:78:30)
at EventEmitter.render (/Users/alatebloomer/node_modules/express/lib/application.js:569:12)
at ServerResponse.render (/Users/alatebloomer/node_modules/express/lib/response.js:961:7)
at /Users/alatebloomer/WebstormProjects/Node_for_Beginner/filename.js:20:9
at Layer.handle [as handle_request] (/Users/alatebloomer/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/alatebloomer/node_modules/express/lib/router/route.js:131:13)

这是我的filename.js

var express = require("express");
var app = express();

app.set('views', __dirname + '/views');
app.set('view engine', 'jade');

app.use(express.static(__dirname + '/public'));

app.get('/myroute', function(req, res){
  res.send('This is GET method');
  res.end();
});

app.post('/myroutee', function(req, res){
  res.send('This is POST method');
  res.end();
});

app.get('/', function(req, res){
  res.render('mypage', {msg1: "Hello world!"});
});

app.listen(12345);

这是我的page.jade

html
   head
       title Hello Jade
   body
       div
           h1 hello #{msg1}

我已经通过“npm install jade -g”

安装了jade

我错过了什么吗?

1 个答案:

答案 0 :(得分:7)

尝试

npm install jade --save
npm install