Home > Software engineering >  Error when installing the latest version of npm
Error when installing the latest version of npm

Time:04-20

I am trying to download the latest version of npm, on the command line, I run the following command: npm install -g npm

I get the following error:

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:

how do I fix this?

CodePudding user response:

It looks like permission was denied, you need to run this command as the administrator.

CodePudding user response:

I think you just need to open the terminal as Administrator, it just says you don't have permission for the file directory.

CodePudding user response:

For Linux

Just use sudo npm install -g npm, This will update the package as an administrator.

For Windows

Right-click on the Windows PowerShell and select to run as administrator and then use cd PATH_TO_DIR to go to the directory of project and then run npm install -g npm

  • Related