使用npm安装yarn
windows下
npm install -g yarn
macos使用以下命令安装
sudo npm install -g yarn —allow-root
然后输入password:xxxxx即可
1、查看当前源
yarn config get registry
2、切换为淘宝源
yarn config set registry https://registry.npm.taobao.org
3、切换为自带的
yarn config set registry https://registry.yarnpkg.com
1、npm查看镜像配置地址
npm get registry
2、还原npm镜像配置
npm config set registry https://registry.npmjs.org/
3、查看npm镜像配置,会发现已经变了
npm get registry
补充一下安装vue和vue/cli
window下
npm install -g vue @vue/cli
macOS下
sudo npm install -g vue @vue/cli —allow-root
输入密码pssword:xxxxx即可安装成功
验证安装是否成功
vue -V
vue -h
这两个命令没问题的话就完全没问题了
创建vue项目
vue create 项目名
接下来自定义配置就OK
然后cd 项目名
npm run serve
或者
yarn run serve
即可运行跑起来
但是事实上并不是你只装了一个版本的nodejs就可以了、项目总有不匹配nodejs版本的时候、这个时候就需要安装多版本nodejs。
windows的话建议csdn搜索nvm安装即可
mac的话继续往下看
1、全局安装n工具
sudo npm install -g n —allow-root
2、安装指定版本nodejs
sudo n 16.0.0
3、查看选择nodejs版本
n
上下键切换回撤即可选中