在输入命令npm start
启动运行项目的时候,有时候会遇到这样的错误Error: Cannot find module 'mongoose',缺少mongoose
这个模块。
Error: Cannot find module 'mongoose' at Function.Module._resolveFilename (module.js:536:15) at Function.Module._load (module.js:466:25) at Module.require (module.js:579:17) at require (internal/module.js:11:18) at Object.<anonymous> (D:\loginproject\routes\index.js:3:16) at Module._compile (module.js:635:30) at Object.Module._extensions..js (module.js:646:10) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! loginproject@0.0.0 start: `node ./bin/www` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the loginproject@0.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Program Files\nodejs\node_cache\_logs\2019-01-09T01_53_44_235Z-debug.log
这个时候的解决办法就是,把缺少的模块安装上:
npm install mongoose
运行成功,打开浏览器输入访问地址,就可以看到项目了。