When attempting to install @vue/cli using npm install -g, an error occurred with code 'EACCES' and errno -13

Upon using the terminal, I encountered the following error: npm ERR! code EACCES npm ERR! syscall mkdir npm ERR! path /usr/local/lib/node_modules/@vue npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@vue' npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@vue'] { npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'mkdir', npm ERR! path: '/usr/local/lib/node_modules/@vue' 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/your username/.npm/_logs/2022-12-27T12_34_46_007Z-debug-0.log

Despite following npm install -g @vue/cli from the Vue documentation, I am unsure why it is not functioning as expected.

Answer №1

If you want to resolve the issue quickly, avoid taking the INCORRECT APPROACH:

sudo npm install -g @vue/cli

This method grants excessive access to scripts, potentially opening up vulnerabilities.

There are several solutions to address this problem:

Adjust permissions for the directory where npm packages are installed

The logs indicate a lack of access to /usr/local/lib/node_modules/@vue

To rectify this, execute the following command:

sudo chown -R $USER /usr/local/

Change the location for installing global npm packages

Use the following commands:

mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile
source ~/.profile

This approach is recommended in the npm documentation: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally#manually-change-npms-default-directory

Opt for using nvm instead of the standard node installation

I personally recommend this option

You can find instructions for installing and configuring nvm here:

https://github.com/nvm-sh/nvm#installing-and-updating

Answer №2

I encountered an npm errno - 13 (Permission denied. The operation was rejected by the operating system, indicating that the current user lacks permission to access the file.)

Here's how you can resolve this issue:

  1. Run the following command in your terminal: sudo chown -R $USER /usr/local/ (This command changes the privileges for the folder where npm packages are being installed.)

2. Adjust the location where global npm packages are installed.

  • Create a new directory: mkdir ~/.npm-global
  • Set the prefix for npm: npm config set prefix '~/.npm-global'
  • Add the newly created directory to the PATH: echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile
  • Update the profile settings: source ~/.profile
  • Install @angular/cli globally: npm install -g @angular/cli

These steps will successfully install Angular on your local machine.

  • Authored by Vidhi Jayswal

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Animating a div in CSS3 to expand horizontally from left to right without affecting its original position

I am currently in the process of developing a calendar using HTML, CSS, and JavaScript. The main purpose of this calendar is to showcase upcoming and past events. However, I am facing difficulties in ensuring that my event blocks occupy the remaining space ...

Attempting to dynamically change the text of a button in JavaScript without any user interaction

I have created a button function that displays a word's definition when clicked. However, I am now attempting to modify it so that the definitions are shown automatically every few seconds using "SetInterval" without requiring a click. I am unsure of ...

I am attempting to invoke a JavaScript function from within another function, but unfortunately, it does not seem to be functioning

I encountered an issue that is causing me to receive the following error message: TypeError: Cannot read property 'sum' of undefined How can this be resolved? function calculator(firstNumber) { var result = firstNumber; function sum() ...

Is there a slider available for organizing Google Photos collections using JavaScript, Angular, React, or Vue?

I am excited to incorporate a vertical photo slider into my Angular/React app similar to the one seen on the Google Photos website. If you haven't seen it yet, here's a screenshot: of your google account, click this link to view. The slider org ...

Extracting the URL of the @font-face declaration in CSS with the use of JavaScript

Currently, my CSS file contains numerous @font-face tags. Each tag specifies a unique font-family and src URL. @font-face{ font-family: Garamond; src: url('ePrintFonts/pcl_91545.ttf'); } @font-face{ font-family: C ...

Implementing dynamic ID routes in React Router using JSON data

As a beginner in React, I have been working hard to improve my skills every day. However, I am currently facing a challenge with creating dynamic routes using JSON characters (specifically from Dragon Ball Z). Although my routes are set up correctly, I wo ...

Ways to add elements to a non-existent index in an array

I am facing an issue while attempting to form sets of objects in an array and generating a new set if the item is not already present. The structure of the data looks something like this: [ { "order": orderData, "items": itemData }, { "or ...

Optimizing the loading of flash objects to improve website

I have successfully implemented the jQuery lazy-loading plugin to defer loading of images below the fold on a large web page. This method works well for images, but now I am looking to apply the same technique to a large Flash object that is also positione ...

The instance does not have a definition for the property or method "names" that is being referenced during rendering

Currently, I'm working on developing a CRUD application using Vue.js and Firebase. However, I've encountered an error that I can't seem to resolve: [Vue warn]: Property or method "names" is not defined on the instance but referenced during r ...

There was an issue with the routing that prevented access to the student activity information at

I've been working on building my own Note Taking App using Express. Following my instructor's example, I wrote some code but encountered an issue when deploying it. Whenever I try to add a new note, I receive an error that says "cannot get/api/na ...

Utilize AngularJS for filtering with nested elements and scope

I'm a bit confused about what's going wrong here. I'm attempting to retrieve the participant of a conversation who has a username that matches the current user's. Here are the scopes in the view: conversation: [{id: 1, ...

Is it possible to determine if a JavaScript/jQuery effect or plugin will function on iPhone and iPad without actually owning those devices?

Is there a way to ensure that a javascript/jquery effect or plugin that works well on all desktop browsers will also work on iPhone and iPad without actually owning those devices? Can I rely on testing it on the latest Safari for Windows to guarantee comp ...

What is the best way to have various texts display after a certain number of clicks?

I am looking for a way to display different text based on the number of clicks within a certain class. For example, if the user clicks twice, the text displayed should be "You clicked two times", and this pattern continues until the fifth click, after whic ...

When updating the innerHTML attribute with a new value, what type of performance enhancements are implemented?

Looking to optimize updating the content of a DOM element called #mywriting, which contains a large HTML subtree with multiple paragraph elements. The goal is to update only small portions of the content regularly, while leaving the majority unchanged. Co ...

Save the value entered into an input field using JavaScript and store it in a PHP variable

For a question, I'm developing a dynamic text field where the answer will be displayed based on the user's selection from the answer field. Once the user submits their answer, the PHP code saves it in a PHP variable named $ans1. However, when the ...

Is it possible to transform a Uint8Array into a boolean array without relying on strings?

My JavaScript skills are a bit rusty, especially when it comes to bit arithmetic. The task at hand is converting a UInt8Array into 11-bit numbers. I need these numbers for a bip39 wordlist so that I can convert a libsodium private box key into a mnemonic. ...

Uploading Files with Additional Information in Angular

I am currently utilizing the Angular-file-upload library to upload files to an API. This is how I'm approaching it: var uploadFile = function (file) { return $upload.upload({ url: '/api/place/logo', data: {place_id: 1, t ...

Switching background images for DIVs when links are rolled over

Having trouble changing the background image of a div when a user hovers over a link. Any ideas on what might be causing this issue? <style> #divToSwap { background-image: url(black.jpg); height: 150px; width: 150px; } </style> &l ...

Is the Vue.js 2.x composition API completely compatible with TypeScript?

After migrating our vue.js 2.x project to typescript, I came across Evan You's comment in this issue: https://github.com/vuejs/rfcs/pull/17#issuecomment-494242121 The Class API proposal has been dropped, so I switched to the regular option-based ver ...

Creating a regular expression to separate numbers and letters

I am faced with the following dilemma. var s = "23BE"; Can anyone guide me on how to utilize regular expressions to split this string into 23 and BE? I attempted to solve it with the code snippet below: var regex = /([A-Z][a-z]+)/; match = regex.exec(s ...