Home > OS >  NPM installation errors
NPM installation errors

Time:10-17

I am trying to create a new project and wanted to install NPM in the directory of my project, but it showed these errors. I currently have the latest versions of both NPM and Node.js.

Naomis-Air:~ naomivictoriaobame$ npm -v
7.24.0
Naomis-Air:~ naomivictoriaobame$ npm install npm@latest -g
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR!  [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/usr/local/lib/node_modules/npm',
npm ERR!   dest: '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/naomivictoriaobame/.npm/_logs/2021-10-16T20_55_50_627Z-debug.log
Naomis-Air:~ naomivictoriaobame$  npm cache clean --force
npm WARN using --force Recommended protections disabled.
Naomis-Air:~ naomivictoriaobame$

CodePudding user response:

It looks as though the current user needs permission to make change to the npm directory. You can run the following command to give the current user access modify that directory:

sudo chown -R $(whoami) ~/.npm

CodePudding user response:

You'd have to run with sudo, in order to install -g lobally:

sudo npm install npm@latest -g
  • Related