mac和windows都适用,mac需要sudo,win不需要
先安装这个(无脑安装,一直点下一个)
http://nodejs.cn/download/
查看版本
node -v
2.安装Vue
说明:vue依托nodejs,vue只是node万千包中的一个。
1.先查看电脑里有没有安装vue: 命令:vue -V //注意V大写,
若提示 command not found 则进行下一步;
若提示版本号为:2.9.6 ,则需要卸载这一版本
2.新版vue脚手架安装命令(mac):sudo npm install -g @vue/cli
win系统命令(必须要在管理员权限下安装) :install -g @vue/cli
前面加sudo 是获取系统的权限,之后需要输入密码,不加sudo可能因为权限的问题安装失败。
vue -V 显示安装版本,则安装成功
卸载旧版vue
npm uninstall -g vue-cli
下载脚手架(mac)
sudo npm install -g @vue/cli
下载脚手架(win)
npm install -g @vue/cli
查看版本
vue -V
创建项目命令
vue create hello-world
运行项目
npm run serve
使用webpack搭建项目失败 使用npm报错
mac:Vue newer$ npm install -g @vue/cli-init
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/@vue/cli-init
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@vue/cli-init'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@vue/cli-init'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/@vue/cli-init'
npm ERR! }
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/newer/.npm/_logs/2022-04-11T13_36_40_471Z-debug-0.log
使用 sudo npm install -g @vue/cli-init
Command vue init requires a global addon to be installed.
Please run npm i -g @vue/cli-init and try again.
mac:Vue newer$ sudo npm install -g @vue/cli-init