uni-app运行项目时报错--解决办法

时间:2024-03-16 10:25:33

报错信息:
/ 开始编译当前项目至 mp-weixin 平台…

[email protected] dev:mp-weixin D:\桌面\momopic
ERROR Failed to compile with 1 errors 9:11:48 ├F10: AM┤

This dependency was not found:

  • vue/types/umd in ./node_modules/babel-loader/lib!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader??ref–12-1!./node_modules/@dcloudio/webpack-uni-mp-loader/lib/script.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib??vue-loader-options!./node_modules/@dcloudio/webpack-uni-mp-loader/lib/style.js!./src/pages/home/home-recommend/index.vue?vue&type=script&lang=js&

To install it, you can run: npm install --save vue/types/umd
ERROR Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev:mp-weixin: cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin vue-cli-service uni-build --watch
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev:mp-weixin 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\gzh\AppData\Roaming\npm-cache_logs\2020-10-06T01_11_48_908Z-debug.log
原图:
uni-app运行项目时报错--解决办法
小程序里面报错信息1:
VM328:1 MiniProgramError
Cannot find module ‘vue/types/umd’
Error: Cannot find module ‘vue/types/umd’
uni-app运行项目时报错--解决办法

小程序里面报错信息2:
VM328:1 SystemError (jsEnginScriptError)
Component is not found in path “pages/home/home-recommend/index” (using by “pages/home/index”)
Error: Component is not found in path “pages/home/home-recommend/index” (using by “pages/home/index”)
uni-app运行项目时报错--解决办法
根据小程序报错信息2,发现Error: Component is not found in path “pages/home/home-recommend/index” (using by “pages/home/index”),
回去翻了翻代码文件,发现多了一行,不是我自己写进去的
uni-app运行项目时报错--解决办法
解决办法:删掉那行 import { component } from ‘vue/types/umd’;
即可,就可以正常运行项目了。
导致这个错误的原因是我import的时候按回车,编译器自动帮我加上去的,开始以为是程序自动补上,然后没删掉,神奇的是我第一遍注释掉那句话 编译还是出错,第二遍再来的时候就解决了。。。。。