vue-cli3系列一:vue-cli3的安装

304 阅读1分钟

安装环境

Vue CLI 需要 Node.js 8.9 或更高版本 (推荐 8.11.0+)。

安装命令

全局安装:

npm install -g @vue/cli

可以通过vue --version命令查看其版本, 也可以简写为vue -V

在安装过程中出现了一个报错如下:

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/zhuzhanchang/.npm/_logs/2019-09-05T07_45_32_917Z-debug.log
  • 原因: 执行命令行命令时没有获得管理员权限

  • 解决方案:在命令行前面添加sudo获取管理员权限,输入管理员密码就行,例如原来的是: npm install -g @vue/cli,应该改为:sudo npm install -g @vue/cli 然后再输入电脑密码就行

目前为止,只是在你的电脑上全局安装了vue-cli3,接下来就可以用vue create进行项目的创建