1、下载node
https://nodejs.org/en/#download
下载后根据安装向导一直安装就可以,查看版本号,如果有版本号就是安装成功了
node -v
npm -v
2、安装淘宝镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
如果出现错误信息,是因为没有权限
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
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: "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!
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/mac/.npm/_logs/2020-03-17T03_10_41_111Z-debug.log
执行命令sudo npm install -g cnpm --registry=https://registry.npm.taobao.org成功
执行命令cnpm -v查看版本
3、安装vue
sudo cnpm install -g vue-cli
输入vue
4、安装webpack模板,并设置工程信息
输入命令 vue init webpack my-project,就可以创建一个叫my-project的工程
5、进入项目,安装并运行
cd my-project cnpm install cnpm run dev
访问http://localhost:8080,可以看到页面