前言
因为我电脑重装了一下,需要重新安装Vue,那么好,本期我们就来讲解如何安装Vue。
nodejs安装
安装Vue脚手架前,我们需要安装一个node包,官网地址nodejs.org/
Vue安装
在cmd中输入,npm install vue -g
意思是全局下载Vue脚手架,如果报错:
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmjs.org/vue failed, reason: connect ETIMEDOUT 104.16.24.34:443
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
解决方案:换个镜像,不用node镜像可以用淘宝镜像
- 查看npm当前镜像
npm config get registry - 设置成淘宝镜像
npm config set registry https://registry.npm.taobao.org - 再次查看npm镜像
npm config get registry
然后下载npm install vue -g
下载成功后,输入npm info vue查看vue具体信息。
输入npm list vue查看版本号。
webpack安装
输入:npm install webpack -g安装webpack。
webpack4.X版本以上都需要安装webpack-cli,npm install --global webpack-cli
然后可以使用webpack -v查看版本号。
安装脚手架
安装前需要卸载旧版本
卸载2.x版本 npm uninstall vue-cli -g
卸载3.x版本 npm uninstall @vue/cli -g
然后下载新版本:npm install @vue/cli –g
同时可以指定版本号,不指定则自动下载最新版本npm install -g @vue/cli@3.12.1
然后使用vue create 项目名,则可以创建项目
ERROR Error: EPERM: operation not permitted, mkdir报错上述代码可以通过管理员打开npm即可解决。