Day075 — Avoid “Error: EACCES: permission denied”
1 min readMay 11, 2019
When I want to install a package globally, Error: EACCES: permission denied
occurs.
If you see an EACCES error when you try to install a package globally, you can either:
Reinstall npm with a node version manager (recommended),
or
Manually change npm’s default directory
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
Therefore, I reinstall npm with a node version manager.
To uninstall installed nodejs:
- go to /usr/local/lib and delete any node and node_modules
- go to /usr/local/include and delete any node and node_modules directory
To install nodejs via nvm:
# install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
# verify installation
command -v nvm
# install the latest node
nvm install node
To install a specific version of node:
nvm install 6.14.4 # or 10.10.0, 8.9.1, etc
reference: