'I couldn't install npm on my mac. I got the following errors
I am getting following checkPermissions error related write access while doing npm install.
npm install
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/tar/node_modules
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib'
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mac/.npm/_logs/2018-02-08T17_10_28_286Z-debug.log .
Please provide some reference or information.
Solution 1:[1]
Use sudo in front of your install command and enter your password when prompted. It installs NPM into the global space, which requires SUDO if you are not on the root account.
That is what this part of the error is telling you: "Please try running this command again as root/Administrator."
Solution 2:[2]
After you install npm, you will have issues with global packages. Use this suggested way of resolving it. Better, secure & maintainable.
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
nano ~/.zprofile
# Add a line to add the new dir to path, eg:
# PATH="~/.npm-global/bin":$PATH
# export PATH
source ~/.zprofile
Ref: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Korgrue |
Solution 2 | Anand Rockzz |