很多同学在前后分离的过程中发现前端报错无法运行
接下我给同学们操作演示下解决办法
1:nodejs版本必须是我们提供的14.5 win+r输入cmd执行npm -v查看版本
2:原front文件内的package.json缺少依赖,我们也要覆盖替换进去新的package.json
3:将node_modules_front复制到分离出来的front文件夹并解压到当前文件夹内
4:在front文件夹执行cmd输入npm run serve/yarn serve
注意 如果第一次执行报错,关闭命令指示符窗口再次输入npm run serve/yarn serve即可
{
"name": "front",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"element-ui": "^2.15.5",
"vue": "^2.6.11",
"vue-baidu-map": "^0.21.22",
"vue-quill-editor": "^3.0.6",
"vue-resource": "^1.5.3",
"vue-router": "^3.5.2",
"vue2-countdown": "^1.0.8",
"vuex": "^3.1.1"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"node-sass": "^4.13.1",
"sass-loader": "^8.0.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}