npm ERR! code MODULE_NOT_FOUND in node 7 and 8 after installing 4.1.2

Created on 30 Jul 2017  ·  3Comments  ·  Source: tj/n

Issue Template:

Describe issue including what OS you are using

macOS Sierra 10.12.5

Describe what version of N you have

n --version 2.1.7 (via Homebrew)

Describe how you installed N

brew install n

Steps to reproduce issue _1.2.3_

Fresh installation, no node/npm installed previously

  1. n stable
    install : node-v8.2.1
    mkdir : /usr/local/n/versions/node/8.2.1
    fetch : https://nodejs.org/dist/v8.2.1/node-v8.2.1-darwin-x64.tar.gz
    node -v v8.2.1
    npm -v 5.3.0
    npm doctor
    Check Value Recommendation
    npm ping OK
    npm -v v5.3.0
    node -v v8.2.1
    npm config get registry https://registry.npmjs.org/
    which git /usr/local/bin/git
    Perms check on cached files ok
    Perms check on global node_modules ok
    Perms check on local node_modules ok
    Verify cache contents verified 969 tarballs
  2. n 4.1.2
    install : node-v4.1.2
    mkdir : /usr/local/n/versions/node/4.1.2
    fetch : https://nodejs.org/dist/v4.1.2/node-v4.1.2-darwin-x64.tar.gz
    node -v v4.1.2
    npm -v 2.14.4
  3. n 8.2.1
    npm doctor
    npm ERR! code MODULE_NOT_FOUND
    npm ERR! Cannot find module 'internal/fs'
    npm ERR! A complete log of this run can be found in:
    npm ERR! /Users/name/.npm/_logs/2017-07-30T01_22_21_881Z-debug.log

Describe the results you received

npm list -g --depth=0
/usr/local/lib
└── [email protected]

npm ERR! missing: npm-package-arg@^4.0.0, required by [email protected]
npm ERR! invalid: [email protected] /usr/local/lib/node_modules/npm/node_modules/cmd-shim/node_modules/graceful-fs
npm ERR! invalid: [email protected] /usr/local/lib/node_modules/npm/node_modules/node-gyp/node_modules/glob
npm ERR! invalid: [email protected] /usr/local/lib/node_modules/npm/node_modules/node-gyp/node_modules/tar
npm ERR! invalid: [email protected] /usr/local/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/graceful-fs
npm ERR! invalid: [email protected] /usr/local/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream
npm ERR! invalid: [email protected] /usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/has-unicode
npm ERR! invalid: [email protected] /usr/local/lib/node_modules/npm/node_modules/sha/node_modules/graceful-fs

Describe the results you expected

Working [email protected]

What version of npm you are using

No node/npm installed previously, only through n 8.2.1 and n 4.1.2

Additional information you deem important (e.g. issue happens only occasionally):

Could those invalid packages leftovers from node 4.1.2/npm 2.14.4 ( #403 )? Can't update npm myself.
npm install -g npm@latest
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'internal/fs'

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/name/.npm/_logs/2017-07-30T02_09_56_157Z-debug.log

Probably related to/duplicate of #310.

which n /usr/local/bin/n

(paste your output here)

Most helpful comment

Try reinstall npm:

$ curl -0 -L https://npmjs.com/install.sh | sudo sh

You might not need sudo

If doesn't work still, try re-install node.
If you installed node with brew, try:

$ brew uninstall node
$ brew install node

If you still having issues after that, try this solution

All 3 comments

Try reinstall npm:

$ curl -0 -L https://npmjs.com/install.sh | sudo sh

You might not need sudo

If doesn't work still, try re-install node.
If you installed node with brew, try:

$ brew uninstall node
$ brew install node

If you still having issues after that, try this solution

I tried the steps @leocaseiro suggested, but that didn't work for me. Oddly re-installing it from the GUI worked (https://nodejs.org/en/download/) -- which installed version Node v8.11.1, NPM 5.6.0. For reference I'm on OSX 10.12.6.

Just wanted to add this comment in case it helps others resolve this issue!

This issue was hopefully fixed by #470

This issue has not had any activity in over six months. It isn't likely to get acted on due to this report.

Feel free to open a new issue if it comes up again, with new information and renewed interest.

Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings