11

I'm trying to run this command:

npm ci

And it returns this error:

npm ERR! pkg-dir not accessible from find-cache-dir

What am I missing here?

craftsman
  • 15,133
  • 17
  • 70
  • 86

3 Answers3

6

So it turned out that my package-lock.json file was out of sync with package.json. I ran npm i, which regenerated an in-sync version of package-lock.json, which I eventually used in other environments to successfully run npm ci command.

craftsman
  • 15,133
  • 17
  • 70
  • 86
  • 2
    I'm having the same problem but this solution isn't working for me. – Ian Gilham Mar 06 '19 at 11:54
  • @IanGilham Did anything work for you? Issues like these are annoying, and it'd be good to know what worked for you for future reference. – craftsman Mar 06 '19 at 22:13
  • 4
    I got it working after downgrading npm to version **6.4.1**, which is the same version used by our automated build system.It turns out that there is absolutely no guarantee that `package-lock.json` files are compatible with minor releases of npm itself, so they need constant regeneration. I'm not sure if the two observations are related, however. – Ian Gilham Mar 08 '19 at 13:33
3

Just running npm i again didn't fix the issue for me. Deleting my existing package-lock.json and my node_modules folder, then running npm i generated an updated package-lock.json file. Afterwards, npm ci worked.

alexweininger
  • 130
  • 1
  • 6
1

Problem is with compatibility between versions of Node and NPM, in my case upgrading NPM to 8.5.5 and Node to 18.12.1 worked