dcloudio / uni-app

A cross-platform framework using Vue.js
https://uniapp.dcloud.io
Apache License 2.0
40.15k stars 3.63k forks source link

TypeError: loaderContext.getOptions is not a function #3302

Closed MobroChu closed 2 years ago

MobroChu commented 2 years ago

问题描述 项目按照 uniapp 官网文档进行搭建、项目一个月前能正常运行,隔了一个月未修改任何代码,项目运行不起来了。报错如下:

image

复现步骤

  1. 启动命令 npm run dev:mp-weixin,项目前一周还能正常运行跑起来
  2. 出现上面 TypeError: loaderContext.getOptions is not a function 报错

看了很多网上的大佬们说是 lessless-loader版本不正确,我就将lessless-loader版本换了很多版本,还是不行。 下面是我的 package.json 部分包版本:

image image

以下是 vue.config.js 配置:

image

系统信息:

lubrication@0.1.0 info /Users/mobro/mobro.site/lubrication node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js

uni-app v3.3.11 uni-app cli v2.0.1-33920220208001

Environment Info:

System: OS: macOS 11.4 CPU: (8) x64 Apple M1 Binaries: Node: 12.3.1 - ~/.nvm/versions/node/v12.3.1/bin/node Yarn: 1.16.0 - ~/.nvm/versions/node/v12.3.1/bin/yarn npm: 6.9.0 - ~/.nvm/versions/node/v12.3.1/bin/npm Browsers: Chrome: 98.0.4758.109 Firefox: 70.0.1 Safari: 14.1.1 npmPackages: @dcloudio/types: => 2.5.17 @dcloudio/uni-app-plus: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-app-plus-nvue: 0.0.1 @dcloudio/uni-app-plus-nvue-v8: 0.0.1 @dcloudio/uni-automator: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-cli-i18n: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-cli-shared: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-h5: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-helper-json: => 1.0.13 @dcloudio/uni-i18n: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-migration: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-mp-360: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-mp-alipay: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-mp-baidu: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-mp-kuaishou: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-mp-lark: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-mp-qq: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-mp-toutiao: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-mp-vue: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-mp-weixin: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-quickapp-native: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-quickapp-webview: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-stat: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-template-compiler: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/uni-ui: ^1.4.9 => 1.4.12 @dcloudio/vue-cli-plugin-hbuilderx: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/vue-cli-plugin-uni: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/vue-cli-plugin-uni-optimize: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/webpack-uni-mp-loader: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @dcloudio/webpack-uni-nvue-loader: 0.0.1 @dcloudio/webpack-uni-pages-loader: ^2.0.1-33520211229002 => 2.0.1-33920220208001 @hap-toolkit/dsl-vue: 0.6.13 @vue/babel-helper-vue-jsx-merge-props: 1.2.1 @vue/babel-helper-vue-transform-on: 1.0.2 @vue/babel-plugin-jsx: 1.1.1 @vue/babel-plugin-transform-vue-jsx: 1.2.1 @vue/babel-preset-app: 4.5.15 @vue/babel-preset-jsx: 1.2.4 @vue/babel-sugar-composition-api-inject-h: 1.2.1 @vue/babel-sugar-composition-api-render-instance: 1.2.4 @vue/babel-sugar-functional-vue: 1.2.2 @vue/babel-sugar-inject-h: 1.2.2 @vue/babel-sugar-v-model: 1.2.3 @vue/babel-sugar-v-on: 1.2.3 @vue/cli-overlay: 4.5.15 @vue/cli-plugin-babel: ^4.5.0 => 4.5.15 @vue/cli-plugin-router: 4.5.15 @vue/cli-plugin-typescript: * => 5.0.1 @vue/cli-plugin-vuex: 4.5.15 @vue/cli-service: ^4.5.0 => 4.5.15 @vue/cli-shared-utils: 4.5.15 @vue/component-compiler-utils: 3.3.0 (3.3.0) @vue/devtools-api: 6.0.0-beta.15 @vue/preload-webpack-plugin: 1.1.2 @vue/shared: ^3.0.0 => 3.2.31 @vue/web-component-wrapper: 1.3.0 mpvue-page-factory: 1.0.1 mpvue-template-compiler: 1.0.13 uni-h5-vue: 2.6.10 uni-mp-vue: 2.6.10 vue: ^2.6.11 => 2.6.14 vue-class-component: ^6.3.2 => 6.3.2 (7.2.6) vue-hot-reload-api: 2.3.4 vue-lazyload: 1.2.3 vue-loader: 15.9.8 (16.8.3, 15.9.8) vue-property-decorator: ^8.0.0 => 8.5.1 vue-router: 3.0.1 vue-style-loader: 4.1.3 (4.1.3) vue-template-compiler: ^2.6.11 => 2.6.14 (2.6.14) vue-template-es2015-compiler: 1.9.1 vue3: 1.0.0 vuex: ^3.2.0 => 3.6.2 (3.6.2) npmGlobalPackages: @vue/cli: 3.8.2

isNeilLin commented 2 years ago

请问解决了吗?我也遇到了这个问题

MobroChu commented 2 years ago

@isNeilLin 还没有解决,在忙别的项目今天,大佬你要是解决了记得带带老弟~

isNeilLin commented 2 years ago

@MobroChu 好的

isNeilLin commented 2 years ago

@MobroChu 我把ts-loader降级到8.3.0可以了 https://stackoverflow.com/questions/68016372/webpack-ts-loader-error-loadercontext-getoptions-is-not-a-function

MobroChu commented 2 years ago

@isNeilLin 谢谢老铁,这个方法我之前试过了,不得行。

isNeilLin commented 2 years ago

@MobroChu 那你把package.json的 @vue/cli-plugin-typescript 的版本号改成 4.5.13 试试呢

MobroChu commented 2 years ago

@isNeilLin 我找到问题解决了,就是你说的这个包的问题,他每次都用的最新的包,我降版本处理了。谢谢大佬~ https://blog.csdn.net/weixin_41610178/article/details/123292109?spm=1001.2014.3001.5501

isNeilLin commented 2 years ago

@MobroChu 嗯嗯

fxy060608 commented 2 years ago

https://github.com/dcloudio/uni-preset-vue/commit/7c7069c7f3e558a4f266da62dbfa2a02344120c7

imaxing commented 1 year ago

哎 服了呀, 真就是没有更新任何包就突然出这个问题 按照大佬们的方案修改版本仍然没效果 求助!!!

image