mac 無(wú)法安裝vue-cli

1. 無(wú)法安裝vue-cli

在網(wǎng)上查的,是因?yàn)閛s版本過(guò)高的問(wèn)題。安裝 npm install -g @vue/cli時(shí)會(huì)出現(xiàn)這個(gè)問(wèn)題

npm WARN deprecated fsevents@1.2.9: One of your dependencies needs to upgrade to fsevents v2: 1) Proper nodejs v10+ support 2) No more fetching binaries from AWS, smaller package size
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
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/dove/.npm/_logs/2019-11-14T07_30_27_188Z-debug.log

解決辦法:
在終端輸入這個(gè)命令

sudo chown -R $(whoami) /usr/local/*

然后再運(yùn)行npm install -g @vue/cli就可以正常安裝了。

2. 安裝vue-cli之后,發(fā)現(xiàn)終端并沒(méi)有vue

終端輸入vue,發(fā)現(xiàn)未找到,command not find:vue
這個(gè)問(wèn)題應(yīng)該是環(huán)境變量沒(méi)配置,配置一下環(huán)境變量

  1. 首先安裝一下vue-cli
sudo npm intall -g vue-cli

就算上面安裝了@vue/cli,這個(gè)vue-cli也是要安裝的
安裝后是這樣的


安裝vue-cli
  1. 繼續(xù)在終端輸入export PATH="$PATH:/usr/local/bin/vue",$PATH:后面這個(gè)就是上圖中標(biāo)紅的
  2. 到此vue就可以正常使用了
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容