NPM does not work (cannot find module 'internal / fs' - nodejs)

NPM error while updating. I recently upgraded to Node version 7.x. Now npm is not working.

I can not find the error, it may be due to -
npm ERR! Cannot find module 'internal/fs' npm ERR! Cannot find module 'internal/fs' .

I get the following when I run sudo npm update -g -

 npm ERR! Linux 3.13.0-101-generic npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "update" "-g" npm ERR! node v7.1.0 npm ERR! npm v3.10.8 npm ERR! code MODULE_NOT_FOUND npm ERR! Cannot find module 'internal/fs' npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! <https://github.com/npm/npm/issues> 

My /etc/profile.d/nodejs.sh has the following contents:

 NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript export NODE_PATH 
+6
source share
4 answers

You should remove the npm file (usually / usr / local / lib / node_modules / npm) and then reinstall one of the official node tarballs, which includes npm (you can find the latest version http://nodejs.org/dist/latest-v7 .x / ).

Have you updated the version of an older version of node?

If so, this may be the reason why you are having this problem. Older versions of graceful-fs (npm dependent) did things that were no longer available in node v7.

+4
source

According to this thread, updating npm to version 4 will solve your problem, try:

 npm i -g npm@4 

If this does not work, try:

 ~/.n/n/versions/node/7.0.0/bin/npm i -g npm@4 
+1
source

delete the node_modules directory and then enter the console "npm install". For the reason that I do not know if you are only updating npm, this does not fix the error, but reinstalling npm will be fine.

0
source

For me, if I encounter the error “I can’t find the internal / fs module”, it will refer to the command path. Better to find the path to the command:

 npm config get prefix 

enter the path to the system. It works for me after encountering an error for several days.

0
source

Source: https://habr.com/ru/post/1012426/


All Articles