npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Unable to install NPM packages after NPM update

Hello, I’m on a MacBook Pro (2017) and I updated NPM from version 5.6.0 to 6.6.0. My Node.js version remained the same at v8.11.1.

I updated by using npm install npm@latest -g in the terminal. It didn’t seem to work the first time, so I did it again with sudo.

Now I cannot install npm packages. npm install doesn’t work in directories that have a package.json file. And I cannot install new packages.

The error is “Cannot find module ‘./access-error.js’” I have the detailed debug log below.

I’ve deleted the top level node_modules folder and also deleted the package-lock.json and tried re-installing the latest version of NPM again with npm install npm@latest -g and I get the same error message.

Below is the debug log with the error. Any help would be greatly appreciated.

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/Users/bostonemac/.npm-global/bin/npm',
1 verbose cli   'install' ]
2 info using npm@6.6.0
3 info using node@v8.11.1
4 verbose stack Error: Cannot find module './access-error.js'
4 verbose stack     at Function.Module._resolveFilename (module.js:547:15)
4 verbose stack     at Function.Module._load (module.js:474:25)
4 verbose stack     at Module.require (module.js:596:17)
4 verbose stack     at require (internal/module.js:11:18)
4 verbose stack     at Object.<anonymous> (/Users/bostonemac/.npm-global/lib/node_modules/npm/lib/install/exists.js:4:19)
4 verbose stack     at Module._compile (module.js:652:30)
4 verbose stack     at Object.Module._extensions..js (module.js:663:10)
4 verbose stack     at Module.load (module.js:565:32)
4 verbose stack     at tryModuleLoad (module.js:505:12)
4 verbose stack     at Function.Module._load (module.js:497:3)
4 verbose stack     at Module.require (module.js:596:17)
4 verbose stack     at require (internal/module.js:11:18)
4 verbose stack     at Object.<anonymous> (/Users/bostonemac/.npm-global/lib/node_modules/npm/lib/install/check-permissions.js:8:14)
4 verbose stack     at Module._compile (module.js:652:30)
4 verbose stack     at Object.Module._extensions..js (module.js:663:10)
4 verbose stack     at Module.load (module.js:565:32)
5 verbose cwd /Applications/MAMP/htdocs/amp-html
6 verbose Darwin 17.7.0
7 verbose argv "/usr/local/bin/node" "/Users/bostonemac/.npm-global/bin/npm" "install"
8 verbose node v8.11.1
9 verbose npm  v6.6.0
10 error code MODULE_NOT_FOUND
11 error Cannot find module './access-error.js'
12 verbose exit [ 1, true ]

Thanks,

Mike


I found that I have 2 versions of NPM installed in 2 different locations.

“/Users/bostonemac/.npm-global/bin/npm” -v
6.6.0

“/usr/local/bin/npm” -v
5.6.0

I want to remove 6.6.0 and just use 5.6.0 like it was before…Any ideas on how I can do that? Thank you so much.


This is fixed.

I had to remove the locally installed version:

rm -rf “/Users/bostonemac/.npm-global/bin/npm”

Now it works. Hope somebody finds this helpful.