vue项目编译错误处理


问题描述

...
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.
 error  in ./src/assets/icons/bx-analyse.svg?inline

Module build failed (from ./node_modules/vue-svg-icon-loader/lib/index.js):
Error:

Vue packages version mismatch:

- vue@2.6.11 (/path/to/project/node_modules/vue/dist/vue.runtime.common.js)
- vue-template-compiler@2.6.12 (/path/to/project/node_modules/vue-template-compiler/package.json)

This may cause things to work incorrectly. Make sure to use the same version for both.
If you are using vue-loader@>=10.0, simply update vue-template-compiler.
If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.

    at Object.<anonymous> (/path/to/project/node_modules/vue-template-compiler/index.js:10:9)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/path/to/project/node_modules/vue-svg-component-builder/lib/index.js:4:31)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/path/to/project/node_modules/vue-svg-icon-loader/lib/index.js:4:37)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)

 @ ./src/core/icons.js 9:0-62 11:0-22
 @ ./src/config/router.config.js
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://192.168.0.1:8000/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
...
(base) itaken@itaken-home:~/path/to/project$ npm list vue -g
/pat/to/node/lib
└─┬ @vue/cli@4.3.1
  └── vue@2.6.11

(base) itaken@itaken-home:~/path/to/project$ npm list vue-template-compiler -g
/pat/to/node/lib
├─┬ @tarojs/cli@3.0.24
│ └─┬ npm-check@5.9.2
│   └─┬ depcheck@0.8.3
│     └── vue-template-compiler@2.6.12
└─┬ @vue/cli@4.3.1
  └─┬ vue-jscodeshift-adapter@2.1.0
    └── vue-template-compiler@2.6.11

使用npm update 无效.

解决方案

修改项目package.json, 将 vuevue-template-compiler 保持一样的版本即可.

{
  "name": "itaken",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    ...
  },
  "dependencies": {
    ...
    "vue": "^2.6.11",
    ...
  },
  "devDependencies": {
    ...
    "vue-template-compiler": "^2.6.11"
  }
}

参考文档


Author: Itaken
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Itaken !
  TOC目录