Installing bootstrap locally via NPM causes EACCES error

Advertisements

Title speaks for itself mostly.

Upon trying to install bootstrap in my project:

npm i bootstrap@5.2.3

I receive error codes:

npm ERR! syscall open
npm ERR! path /Users/samgoldrick/package.json
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, open '/Users/samgoldrick/package.json'
npm ERR!  [Error: EACCES: permission denied, open '/Users/samgoldrick/package.json'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'open',
npm ERR!   path: '/Users/samgoldrick/package.json'
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.

This is strange because I don’t have issues installing npm packages globally but run into issues installing them locally in projects.

Any help appreciated!

EDIT

Complete oversight on my part. I was running commands outside of the project dir accidentally, forgot to cd in using vscode terminal, thanks for the answers regardless.

>Solution :

The issue you’re facing is due to a permissions problem. Your current user does not have the necessary permissions to access the package.json file. Here’s how to fix it:

cd /path/to/your/project

Change the ownership of the project directory and its contents to your current user. You will need to run this command with administrative privileges using sudo: sudo chown -R $(whoami) .

This command will prompt you for your password. Enter your password and press Enter.

Then try to install bootstrap again:
npm i bootstrap@5.2.3

Leave a ReplyCancel reply