我正在尝试创建 Node Restful API 服务,但 npm 在启动时给了我一个错误。在命令提示符下,我输入了以下内容:
D:\xampp\htdocs\todoListApi>npm run start
todolistapi@1.0.0 开始 D:\xampp\htdocs\todoListApi
nodemon server.js
它显示以下错误
[nodemon] 1.17.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
internal/modules/cjs/loader.js:550
throw err;
^
Error: Cannot find module 'safe-buffer'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.Module._load (internal/modules/cjs/loader.js:475:25)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at Object.<anonymous> (D:\xampp\htdocs\todoListApi\node_modules\readable-str
eam\lib\_stream_readable.js:55:14)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todolistapi@1.0.0 start: `nodemon server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todolistapi@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\admin\AppData\Roaming\npm-cache\_logs\2018-04-20T06_50_15_
033Z-debug.log
D:\xampp\htdocs\todoListApi>npm install mongoose --sav
npm WARN todolistapi@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fse
vents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@
1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
相反,它应该启动 npm 并将结果显示为
待办事项列表 RESTful API 服务器开始于:3000
请指导我如何克服这个问题。