permission denied while trying to install vue/cli

Viewed 20690

I'm trying to install vue cli in my project and I get that error, I'm a new MacOs user. hope you can help me fix it and install vue cli in my project.

Circus-MBP:TodoApp circus4$ npm i  @vue/cli -g

npm ERR! path ../lib/node_modules/@vue/cli/bin/vue.js
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall symlink
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/@vue/cli/bin/vue.js' -> '/usr/local/bin/vue'
npm ERR!  { [Error: EACCES: permission denied, symlink '../lib/node_modules/@vue/cli/bin/vue.js' -> '/usr/local/bin/vue']
npm ERR!   cause:
npm ERR!    { Error: EACCES: permission denied, symlink '../lib/node_modules/@vue/cli/bin/vue.js' -> '/usr/local/bin/vue'
npm ERR!      errno: -13,
npm ERR!      code: 'EACCES',
npm ERR!      syscall: 'symlink',
npm ERR!      path: '../lib/node_modules/@vue/cli/bin/vue.js',
npm ERR!      dest: '/usr/local/bin/vue' },
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, symlink \'../lib/node_modules/@vue/cli/bin/vue.js\' -> \'/usr/local/bin/vue\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../lib/node_modules/@vue/cli/bin/vue.js',
npm ERR!   dest: '/usr/local/bin/vue' }
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).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Circus4/.npm/_logs/2019-10-07T12_38_25_842Z-debug.log
5 Answers

It seem's that you do not have the required privileges to install globally. You could either try installing with sudo or (recommended) move NPM's default directory to one which you have read/write permissions on:

  1. Create directory in your home directory, say ~/.npm-global.

  2. run npm config set prefix '~/.npm-global'

  3. Update your PATH: export PATH=~/.npm-global/bin:$PATH

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

Notice that while you could probably just use sudo, this is highly discouraged. It even says so in the error output you posted:

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).

You need to have permission by writing sudo at the first of your command

sudo npm i  @vue/cli -g

Updated

Or as Philip said it would be better than my answer

  1. Create a directory in your home directory, say ~/.npm-global.

  2. run npm config set prefix ~/.npm-global

  3. Update your PATH: export PATH=~/.npm-global/bin:$PATH

You don't have enough permissions. Try with sudo:

sudo npm i -g @vue/cli

Try it :


Log in as administrator

sudo su

And run

yarn global add @vue/cli

The other option is to give permissions to your user to allow global installs on /usr/local by running this:

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