Vue再执行npm run serve时报如下错误,啥都找不到,这时候前面的Element-UI啥的都装好了,这里只装了一个vue-router后就这样了。

-  Building for production...

 ERROR  Failed to compile with 45 errors                                                                                                                                                                                     15:15:36

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'computed' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'computed' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'computed' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'computed' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'computed' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'computed' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'computed' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'computed' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'computed' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'computed' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'computed' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'defineComponent' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'defineComponent' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'getCurrentInstance' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'getCurrentInstance' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'h' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'h' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'inject' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'inject' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'inject' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'inject' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'inject' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'inject' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'inject' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'inject' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'inject' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'nextTick' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'onActivated' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'onDeactivated' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'onUnmounted' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'provide' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'provide' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'provide' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'reactive' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'reactive' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'ref' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'shallowRef' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'unref' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'unref' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'unref' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'unref' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'unref' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'watch' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'watch' was not found in 'vue'

 error  in ./node_modules/vue-router/dist/vue-router.mjs

"export 'watchEffect' was not found in 'vue'

 ERROR  Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! default@0.1.0 build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the default@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\12051\AppData\Roaming\npm-cache\_logs\2023-02-26T07_15_36_876Z-debug.log

后来发现vue-router版本太高了,不适用于Vue2,只需要删除vue-router,然后重新安装指定版本就可以了。

npm uninstall vue-router
npm install vue-router@3.5.2

问题解决vue-router官方文档

Logo

前往低代码交流专区

更多推荐