Node.js的Express运行问题处理

由于想在研究node.js的应用,按照正常步骤:

1,装好了node运行环境

2,安装了npm环境

3,运行刚安装npm的程序,用来安装Express到node运行目录的node_modules下:

npm install -g express


这几步都很正常。


使用express 新建了一个测试项目,

使用node app.js来运行项目

出现下面提示:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module 'express'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (D:\test\app.js:6:15)
    at Module._compile (module.js:441:26)
    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)


后来查到,没有将node运行目录下的node_modules中的express 复制到项目目录下的node_modules目录中

复制后,再运行

出现提示:

Error: Cannot find module 'jade'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at View.templateEngine (D:\hello\node_modules\express\lib\view\view.js:134:3
8)
    at Function.compile (D:\hello\node_modules\express\lib\view.js:68:17)
    at ServerResponse._render (D:\hello\node_modules\express\lib\view.js:417:18)


    at ServerResponse.render (D:\hello\node_modules\express\lib\view.js:318:17)
    at D:\hello\routes\index.js:7:7
    at callbacks (D:\hello\node_modules\express\lib\router\index.js:272:11)


后来查到,在mode_modules下没有找到jade,

https://github.com/visionmedia/jade下载jade包

下载后,将包里文件放到项目node_modules\express\node_modules目录下的jade里。

再运行,express创建的测试项目,在IE可以正常浏览。



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值