PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 22, 2022

[FIXED] How do I fix the npm error EACCES: permission denied?

 August 22, 2022     environment-variables, linux, npm, npm-install, path     No comments   

Issue

I tried to start a project with installing npm install -g pnpm as a requirement and I tried npm install but it does work. But npm install -g pnpmshows errors as follow; Below is from the terminal!

npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/pnpm/bin/pnpm.cjs
npm ERR! dest /usr/bin/pnpm
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/pnpm/bin/pnpm.cjs' -> '/usr/bin/pnpm'
npm ERR!  [OperationalError: EACCES: permission denied, symlink '../lib/node_modules/pnpm/bin/pnpm.cjs' -> '/usr/bin/pnpm'] {
npm ERR!   cause: [Error: EACCES: permission denied, symlink '../lib/node_modules/pnpm/bin/pnpm.cjs' -> '/usr/bin/pnpm'] {
npm ERR!     errno: -13,
npm ERR!     code: 'EACCES',
npm ERR!     syscall: 'symlink',
npm ERR!     path: '../lib/node_modules/pnpm/bin/pnpm.cjs',
npm ERR!     dest: '/usr/bin/pnpm'
npm ERR!   },
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../lib/node_modules/pnpm/bin/pnpm.cjs',
npm ERR!   dest: '/usr/bin/pnpm'
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.

Solution

  1. Back up your computer.

  2. On the command line, in your home directory, create a directory for global installations:

mkdir ~/.npm-global
  1. Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
  1. In your preferred text editor, open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH

  1. On the command line, update your system variables:
source ~/.profile

  1. To test your new configuration, install a package globally without using sudo:
npm install -g pnpm

source : https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally



Answered By - Javad
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing