1,安装node.js
Node.js官网:https://nodejs.org/en/
进入Node.js官网,选择下载并安装Node.js。安装过程只需要点击“下一步”即可
安装完输入node -v出现版本号表示node安装成功
2.
npm的国内淘宝镜像cnpm 命令行工具代替默认的npm
npm install -g cnpm --registry=https://registry.npm.taobao.org
npm install vue
3.
安装脚手架
sudo c
npm install -g vue-cli
//vue init webpack myvue [这里项目名不能有大写字母]
//myvue是项目名
===================================
Vue中eslint报错的修改,绝对有效!!!
Syntax Error: TypeError: Cannot read properties of undefined (reading 'parseComponent')
You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
————————————————
解决办法:
npm upgrade –latest vue-template-compiler
===================================
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Adminstrtor\AppData\Roaming:这个问题我的是在本地找不到提示的那个文件,所以我就直接:
删除package-lock.json
然后npm init -y
最后npm i
运行项目: npm run dev
打包:npm run build,打包后会出现dist文件夹
nginx启动:brew services start nginx
nginx重启:brew services restart nginx
nginx启动
1、启动nginx:sudo nginx
2、关闭nginx:sudo nginx -s stop
3、重启nginx:sudo nginx -s reload
nginx配置:cd /usr/local/etc/nginx/
vim nginx.conf
把dist路径放在这里:
location / {
root /Users/xxxxx/workspaces/ideaWorkSpace/myVue/mVue/dist;
index index.html index.htm;
}
nginx部署普通h5项目:
在nginx中创建一个文件夹将项目放入,然后在nginx.conf配置指向这个项目路径代理即可:
location /hello {
alias /usr/local/etc/nginx/html/hello;
try_files $uri $uri/ /hello/index.html;
index index.html index.htm;
}
使用webpack创建vue:
1.sudo cnpm install -g vue-cli(安装脚手架)
2.vue init webpack myvue(项目名)