Error installing @vue/cli


(Alan) #1

I am trying to install the vue cli. I am using MacOS Mojave and latest version of node / npm

I was getting different error two days ago and I since uninstalled and reinstalled node and npm

[~]$node -v
v10.15.1
[/]$npm -v
6.4.1

Now getting this error.
[/]$npm install -g @vue/cli
npm WARN deprecated cross-spawn-async@2.2.5: cross-spawn no longer requires a build toolchain, use it instead
npm ERR! path /usr/local/lib/node_modules/.staging/@babel
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rmdir
npm ERR! Error: EACCES: permission denied, rmdir β€˜/usr/local/lib/node_modules/.staging/@babel’
npm ERR! { [Error: EACCES: permission denied, rmdir β€˜/usr/local/lib/node_modules/.staging/@babel’]
npm ERR! stack:
npm ERR! β€˜Error: EACCES: permission denied, rmdir β€˜/usr/local/lib/node_modules/.staging/@babel’’,
npm ERR! errno: -13,
npm ERR! code: β€˜EACCES’,
npm ERR! syscall: β€˜rmdir’,
npm ERR! path: β€˜/usr/local/lib/node_modules/.staging/@babel’ }
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 (though this is not recommended).

I spent half a day yesterday googling and trying various things. Any advice very welcome.

Previously I was running the npm install command from the home folder. Now ran this from root. Should I be doing this? What is the best practice?


(John Gee) #2

I expect that when you reinstalled node and npm, the ownership of the installed files in /usr/local was set to root so you no longer have permission to make changes.

To allow you to do npm global installs to /usr/local without needing sudo (as recommended) you can just claim ownership of the relevant folders.

sudo chown -R $(whoami) /usr/local/lib /usr/local/bin

Then you can ran the install without using sudo:

npm install -g @vue/cli

(There are also other approaches like installing the package locally rather than globally, or change the global package install location by changing the npm settings, or by using a node version manager.)


Error: while installing http-server on MacOS Mojave 10.14.2
(Alan) #3

Thank you. That worked fine.

I have vue cli installed now, and when I tried to create vue project I get another error. Again it is permission related. I wonder whether I may have changed something earlier on the home folder that coud be causing this.

[vue-cli-demo]$vue create default_project

Vue CLI v3.4.0
? Please pick a preset: default (babel, eslint)

Vue CLI v3.4.0
:sparkles: Creating project in /Users/alankavanagh/www/repos/vue/30-days-vue/vue-cli-demo/default_project.
:gear: Installing CLI plugins. This might take a while…

Unhandled rejection Error: EACCES: permission denied, mkdir β€˜/Users/alankavanagh/.npm/_cacache/content-v2/sha1/d6/ea’

Unhandled rejection Error: EACCES: permission denied, mkdir β€˜/Users/alankavanagh/.npm/_cacache/content-v2/sha1/af/df’

Unhandled rejection Error: EACCES: permission denied, mkdir β€˜/Users/alankavanagh/.npm/_cacache/content-v2/sha512/11/09’

Unhandled rejection Error: EACCES: permission denied, mkdir β€˜/Users/alankavanagh/.npm/_cacache/content-v2/sha512/8e/85’

Unhandled rejection Error: EACCES: permission denied, mkdir β€˜/Users/alankavanagh/.npm/_cacache/content-v2/sha512/8e/2e’

Unhandled rejection Error: EACCES: permission denied, mkdir β€˜/Users/alankavanagh/.npm/_cacache/content-v2/sha1/af/ab’

Unhandled rejection Error: EACCES: permission denied, mkdir β€˜/Users/alankavanagh/.npm/_cacache/content-v2/sha512/11/a1’

Unhandled rejection Error: EACCES: permission denied, mkdir β€˜/Users/alankavanagh/.npm/_cacache/content-v2/sha1/6c/01’

Unhandled rejection Error: EACCES: permission denied, mkdir β€˜/Users/alankavanagh/.npm/_cacache/content-v2/sha512/11/c2’

Unhandled rejection Error: EACCES: permission denied, mkdir β€˜/Users/alankavanagh/.npm/_cacache/content-v2/sha1/ff/bc’

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! https://npm.community

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/alankavanagh/.npm/_logs/2019-02-03T08_53_24_354Z-debug.log
ERROR command failed: npm install --loglevel error


(John Gee) #4

Progess! Yes, I suspect left over permission issues from using sudo. Try this:

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

Fingers crossed!


(Alan) #5

Yes! Up and running now. Thanks again :smile:


(system) closed #6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.