0

I am trying to create a Node Restful API service, but npm is giving me an error while starting. In command prompt I have typed the following :

D:\xampp\htdocs\todoListApi>npm run start

todolistapi@1.0.0 start D:\xampp\htdocs\todoListApi

nodemon server.js

It shows following error

[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"}

Instead it should start npm and show result as

todo list RESTful API server started on: 3000

Please guide me on how I can overcome this.

Nicholas K
  • 15,148
  • 7
  • 31
  • 57
Kashyap Patel
  • 1,139
  • 1
  • 13
  • 29

2 Answers2

0

The following steps worked for me :

  • Uninstall Node.js from Control Panel
  • Go C:/Users/Admin/AppData/Roaming
  • Delete npm and npm-cache manually

Try installing node.js again.

Nicholas K
  • 15,148
  • 7
  • 31
  • 57
Kashyap Patel
  • 1,139
  • 1
  • 13
  • 29
0

Try using npm cache clean --force and if it still doesn't work, try to fully re-install NPM/Node :)

HRK44
  • 2,382
  • 2
  • 13
  • 30