首先终端依次执行指令
1、npm config set prefix ‘~/.npm-global’
2、echo ‘export PATH=~/.npm-global/bin:$PATH’ >> ~/.bashrc
3、source ~/.bashrc
4、sudo npm install -g @vue/cli
如果可视化vue 3图形工具报错:
Command failed: vue create test –skipGetStarted –no-git-inlinePreset (“vue Version”: “3”, “use ConfigFiles”false, “plugins” :”@vue/cli-plugin-babel”:&, “@vue/cli-plugin-eslint”: [“config”: “base”, “lintOn”:(“save “Il} * Creating project in /Users/qiugao/Downloads/Project_code/IntelliJ IDEA/kob/test. @ Installing CLI plugins. This might take a while…
npm config get registry(查看镜像源)
mac修改镜像源(很奇怪 mac只能这样改镜像源)
npm config edit
然后在打开的文件中找到 registry= 这一行,将其改为 registry=https://registry.npm.taobao.org,
或 registry=https://registry.npmjs.org/ 保存退出即可。
再npm cache clean –force
最后一步vui ui
vui之后可能会遇到插件安装失败的问题
报错:
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /Users/qiugao/.npm/_cacache/tmp
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 501:20 “/Users/qiugao/.npm”
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/qiugao/.npm/_logs/2023-04-06T11_06_36_234Z-debug-0.log
ERROR Error: command failed: npm install –loglevel error @vue/cli-plugin-vuex@~5.0.0 -D –legacy-peer-deps
解决方法:利用指令sudo chown -R $(whoami) ~/.npm
将该目录所有者更改为当前用户,从而永久解决此问题:
相见恨晚之前百度好久才安装好
chatgpt帮了我大忙 配了两天😭