admin管理员组

文章数量:1406950

Since I have installed yarn, I cannot use npm anymore.

NodeJS is well upgraded. Impossible to remove npm. Every mand I do I got the same error message:

 module.js:487
     throw err;
 ^


 Error: Cannot find module 'safe-buffer'
     at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
   at Module.require (module.js:513:17)     at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:56:14)
    at Module._pile (module.js:569:30)
     at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)     at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)

I got: NodeJS v8.2.1, Yarn v0.27.5 (can't npm -v my npm)

Already tried:

  • remove node_modules folder from my projet and re-install it using npm install (got same error message).
  • npm upgrade, npm cache clear, npm cache rm, npm install safe buffer

I got only 22 lines on my file module.js the error message is talking about, so I cannot have a line 437, 513 or 569 to check.

Since I have installed yarn, I cannot use npm anymore.

NodeJS is well upgraded. Impossible to remove npm. Every mand I do I got the same error message:

 module.js:487
     throw err;
 ^


 Error: Cannot find module 'safe-buffer'
     at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
   at Module.require (module.js:513:17)     at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:56:14)
    at Module._pile (module.js:569:30)
     at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)     at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)

I got: NodeJS v8.2.1, Yarn v0.27.5 (can't npm -v my npm)

Already tried:

  • remove node_modules folder from my projet and re-install it using npm install (got same error message).
  • npm upgrade, npm cache clear, npm cache rm, npm install safe buffer

I got only 22 lines on my file module.js the error message is talking about, so I cannot have a line 437, 513 or 569 to check.

Share edited Aug 15, 2017 at 12:04 zoku 7,2463 gold badges22 silver badges29 bronze badges asked Aug 15, 2017 at 10:10 MeowMeowMeowMeow 931 gold badge2 silver badges8 bronze badges 3
  • Have you googled "Error: Cannot find module 'safe-buffer' at Function.Module._resolveFilename"? There are plenty of similar problems and suggested solutions. Try updating / re-installing NPM. – Steven Commented Aug 15, 2017 at 10:16
  • You need run npm install in the directory with your package.json. – Neji Soltani Commented Aug 15, 2017 at 12:10
  • I tried many thing I found on Google since two days, or similar error. But still got it. I had also removed the node_modules from my project and run npm install (at the same place of my package.jason), but I got the same message for all npm mand. – MeowMeow Commented Aug 15, 2017 at 15:09
Add a ment  | 

3 Answers 3

Reset to default 2

It was impossible to uninstall npm, so I re-install NodeJS from : https://nodejs/en/

And it's finally work.

Actually in my machine even delete global npm or uninstall node.js and install it again but still not work.


so my solution is uninstall npm and go to delete folder npm and npm-cache in C:\Users\pc-name\AppData\Roaming then install it again

I use nvm, so I deleted the node_modules directory there:

rm -rf /Users/shawn/.nvm/versions/node/v6.11.1/lib/node_modules

Then I ran npm install and everything worked.

本文标签: javascriptNPM Cannot find module 39safebuffer39Stack Overflow