我正在尝试使用github中的代码打开网页,无法运行面向错误的服务器并在命令提示符中显示如下:
代码链接:https://github.com/mschwarzmueller/nodejs-basics-tutorial/tree/master/09-mongodb
错误:
05-express-first-app@0.0.0启动C:\ Users \ Atchaya \ Downloads \ nodejs-basics-tutorial-master \ 09-mongodb
节点./bin/www
module.js:471
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Atchaya\Downloads\nodejs-basics-tutorial-master\09-mongodb\app.js:1:77)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 05-express-first-app@0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 05-express-first-app@0.0.0 start script 'node ./bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the 05-express-first-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs 05-express-first-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls 05-express-first-app
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Atchaya\AppData\Roaming\npm-cache\_logs\2017-04-19T14_14_54_505Z-debug.log
答案 0 :(得分:1)
转到09-mongodb
文件夹,然后运行npm install
命令,然后运行npm run start
。
npm install
-
此命令将安装程序包及其依赖的所有程序包。 如果包具有shrinkwrap文件,则安装依赖项 将由此推动。
默认情况下,npm install将安装列出的所有模块 package.json中的依赖项。