由于想在研究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可以正常浏览。