in terminal I get this 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
I found npm install -g @vue/cli
in vue doc and I don't know why it don't work
CodePudding user response:
You can fix it quick but in WRONG WAY writing
sudo npm install -g @vue/cli
But it means that you giving too wide access for these scripts, that can be potentially vulnerable.
There are some ways to solve this problem:
Change privileges do folder where you installing npm packages
From logs you can read that there is no access to /usr/local/lib/node_modules/@vue
So you can write
sudo chown -R $USER /usr/local/
Change place where global npm packages are installed
By commands:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile
source ~/.profile
This is recommended by npm docs https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally#manually-change-npms-default-directory
Use nvm instead of raw node
It is my preferred option
Installation and configuration of nvm is described here: