npm Community Forum (Archive)

The npm community forum has been discontinued.

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

Bug with npm cache on linux

What I Wanted to Do

This happened whenever I tried to install any package locally with npm. The log reported was generated when trying to generate an app with @angular/cli, when it tries to install packages with npm.

What Happened Instead

EACCES errors popped up. All pointed to cache directories in ~/.npm/

Reproduction Steps

I am not sure what caused this error but it occurs whenever I tried to install a package with npm. And it didn’t happen right when I installed node/npm but after some time. I do not recall the particular action performed when this error started appearing.


The error was fixed by owning the .npm directory (chown -R ~/.npm)

node debug.log

0 info it worked if it ends with ok

1 verbose cli [

1 verbose cli '/usr/local/pnpm-global/2/node_modules/',

1 verbose cli '/usr/local/bin/npm',

1 verbose cli 'install',

1 verbose cli '--quiet'

1 verbose cli ]

2 info using npm@6.9.0

3 info using node@v12.4.0

4 verbose npm-session 1f96116fbef9b3f4

5 silly install runPreinstallTopLevelLifecycles

6 silly preinstall first-app@0.0.0

7 info lifecycle first-app@0.0.0~preinstall: first-app@0.0.0

8 silly install loadCurrentTree

9 silly install readLocalPackageData

10 timing stage:loadCurrentTree Completed in 11ms

11 silly install loadIdealTree

12 silly install cloneCurrentTreeToIdealTree

13 timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms

14 silly install loadShrinkwrap

15 timing stage:loadIdealTree:loadShrinkwrap Completed in 2ms

16 silly install loadAllDepsIntoIdealTree

17 timing npm Completed in 2109ms

18 error cb() never called!

19 error This is an error with npm itself. Please report this error at:

20 error <>

Platform Info

Adding more info here. npm and node were installed from the official ubuntu repo and worked fine when first installed.

$ npm --versions
  npm: '6.9.0',
  ares: '1.15.0',
  brotli: '1.0.7',
  cldr: '35.1',
  http_parser: '2.8.0',
  icu: '64.2',
  llhttp: '1.1.3',
  modules: '72',
  napi: '4',
  nghttp2: '1.38.0',
  node: '12.4.0',
  openssl: '1.1.1b',
  tz: '2019a',
  unicode: '12.1',
  uv: '1.29.1',
  v8: '',
  zlib: '1.2.11'
$ node -p process.platform

There is an open issue with installing global packages using sudo leaving behind files with the wrong ownership. I have been referring to this as the canonical bug: Global installs (sudo npm i -g) fail on Mac after 6.5 upgrade. Works fine after 6.4.1 downgrade.