Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

taro小程序正常启动,h5报错 Field 'browser' doesn't contain a valid alias configuration #12869

Closed
zhuxiaoweb opened this issue Nov 23, 2022 · 46 comments
Labels
F-vue3 Framework - Vue 3 T-h5 Target - 编译到 H5 upstream 上游bug, 需要上游修复的 V-3 Version - 3.x

Comments

@zhuxiaoweb
Copy link

相关平台

H5

浏览器版本: chrome最新版
使用框架: Vue 3

复现步骤

yarn dev:h5

期望结果

期望正常运行

实际结果

[HMR] Waiting for update signal from WDS...
app.config.ts?cf92:1 Uncaught (in promise) Error: Cannot find module './app.boot'
at webpackMissingModule (app.config.ts?cf92:1:1)
index.js?e2a7:551 [webpack-dev-server] Hot Module Replacement enabled.
index.js?e2a7:551 [webpack-dev-server] Live Reloading enabled.

环境信息

Taro v3.5.7


  Taro CLI 3.5.7 environment info:
    System:
      OS: macOS 12.5
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 18.12.1 - /usr/local/bin/node
      Yarn: 1.22.19 - /usr/local/bin/yarn
      npm: 8.19.2 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 3.5.7 => 3.5.7 
      @tarojs/components: 3.5.7 => 3.5.7 
      @tarojs/helper: 3.5.7 => 3.5.7 
      @tarojs/plugin-framework-vue3: 3.5.7 => 3.5.7 
      @tarojs/plugin-html: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-alipay: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-jd: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-qq: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-swan: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-tt: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-weapp: 3.5.7 => 3.5.7 
      @tarojs/router: 3.5.7 => 3.5.7 
      @tarojs/runtime: 3.5.7 => 3.5.7 
      @tarojs/shared: 3.5.7 => 3.5.7 
      @tarojs/taro: 3.5.7 => 3.5.7 
      @tarojs/taro-h5: 3.5.7 => 3.5.7 
      @tarojs/webpack5-runner: 3.5.7 => 3.5.7 
      babel-preset-taro: 3.5.7 => 3.5.7 
      eslint-config-taro: 3.5.7 => 3.5.7 

补充信息

macos

@taro-bot2 taro-bot2 bot added F-vue3 Framework - Vue 3 T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Nov 23, 2022
@yoyo837
Copy link
Contributor

yoyo837 commented Nov 23, 2022

是不是在dev下使用了eslint-webpack-plugin插件?

@zhuxiaoweb
Copy link
Author

zhuxiaoweb commented Nov 23, 2022

eslint-

dev使用这些插件,没有用eslint-webpack-plugin:

"@babel/core": "^7.8.0",
"@types/webpack-env": "^1.13.6",
"webpack": "5.69.0",
"@tarojs/webpack5-runner": "3.5.7",
"@tarojs/cli": "3.5.7",
"@vue/babel-plugin-jsx": "^1.0.6",
"@vue/compiler-sfc": "^3.0.0",
"babel-preset-taro": "3.5.7",
"babel-plugin-import": "^1.13.3",
"css-loader": "3.4.2",
"eslint-plugin-vue": "^8.0.0",
"eslint-config-taro": "3.5.7",
"eslint": "^8.12.0",
"stylelint": "9.3.0",
"style-loader": "1.3.0",
"vue-loader": "^17.0.0",
"@typescript-eslint/parser": "^5.20.0",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"typescript": "^3.7.0"

@zhuxiaoweb
Copy link
Author

想知道这个'./app.boot'是做什么的,同样的代码今天重新install就不行了,官方的模板重新install也不行

@zhuxiaoweb
Copy link
Author

只有h5不行,小程序是可以正常运行的

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 23, 2022

是不是dev:h5运行起来结束后直接提示这个错误的? 如果是, 你尝试重新触发一次HMR看看会不会好? 也就是找个文件直接Ctrl+S保存一次.

@zhuxiaoweb
Copy link
Author

是不是dev:h5运行起来结束后直接提示这个错误的? 如果是, 你尝试重新触发一次HMR看看会不会好? 也就是找个文件直接Ctrl+S保存一次.

image

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 23, 2022

截图要表达什么意思? 尝试重新触发一次HMR试过了吗?

@zhuxiaoweb
Copy link
Author

我觉得是这个defineAppConfig方法的问题

@zhuxiaoweb
Copy link
Author

截图要表达什么意思? 尝试重新触发一次HMR试过了吗?

是的 重新保存触发了一次

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 23, 2022

来个demo吧

@zhuxiaoweb
Copy link
Author

来个demo吧

我现在用taro-cli 拉一个模板 vue3 + ts + webpack5 + nutui + scss 的模板,然后yarn install 以后直接yarn dev:h5就报错了,自己没改动代码,但是昨天是可以的,所以我怀疑是不是官方的依赖出问题了

1 similar comment
@zhuxiaoweb
Copy link
Author

来个demo吧

我现在用taro-cli 拉一个模板 vue3 + ts + webpack5 + nutui + scss 的模板,然后yarn install 以后直接yarn dev:h5就报错了,自己没改动代码,但是昨天是可以的,所以我怀疑是不是官方的依赖出问题了

@zhuxiaoweb
Copy link
Author

貌似不只是我一个发现,github上也有其他用vue3 + ts + webpack5 + nutui + scss 的作者今天发现这个问题了

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 23, 2022

用刚拉的项目对比一下旧项目的lock文件看看有什么差异呢?

@zhuxiaoweb
Copy link
Author

用刚拉的项目对比一下旧项目的lock文件看看有什么差异呢?

昨天正常的lock文件删掉了...

@zhuxiaoweb
Copy link
Author

用刚拉的项目对比一下旧项目的lock文件看看有什么差异呢?

你本地的正常的项目可以重新install试试吗?

@helloint
Copy link

我也碰到了,正纳闷了,找到组织了

@helloint
Copy link

helloint commented Nov 23, 2022

昨天还正常的项目,react18+webpack5,今天删掉lock,重新install后,dev:h5可以复现。
附:
package.txt
今天的有问题的.package-lock.txt
昨天的正常的.package-lock.txt
差异有点多,我不太确定要找什么,好像和webpack5关联不大,google了一把没发现匹配的。
demo repo: https://github.com/hint-test/test-taro-react-echarts (删掉lock重新install可以复现,node: 16.10)

@zhuxiaoweb
Copy link
Author

我也碰到了,正纳闷了,找到组织了

这个不会影响到一些生产环境项目吧...

@zhuxiaoweb
Copy link
Author

昨天还正常的项目,react18+webpack5,今天删掉lock,重新install后,dev:h5可以复现。 package.txt 今天的有问题的.package-lock.txt 昨天的正常的.package-lock.txt

这两个文件有点大啊,我试试找下

@zhuxiaoweb
Copy link
Author

来个demo吧

demo来了
https://github.com/yanbowe/taro-vue3-pinia

@yanbowe
Copy link

yanbowe commented Nov 23, 2022

删除lock文件,重新install就会报错

@zhuxiaoweb
Copy link
Author

昨天用h5还有一个问题,nutui里的Range组件在点击进度条给滑块定位的时候会报错,小程序是好的

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 23, 2022

锁定一下[email protected],先跳过. webpack/enhanced-resolve#363

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 23, 2022

等上游看看先吧. 我提了个issue.

@zhuxiaoweb
Copy link
Author

等上游看看先吧. 我提了个issue.

嗯嗯

@yoyo837 yoyo837 removed F-vue3 Framework - Vue 3 T-h5 Target - 编译到 H5 labels Nov 23, 2022
@zhuxiaoweb
Copy link
Author

锁定一下[email protected],先跳过. webpack/enhanced-resolve#363

可能Demo项目可以这样临时解决,
但是我用taro-cli 拉的模板 vue3 + ts + webpack5 + nutui + scss 的模板(github)
用这个办法h5还是出现相同的问题.

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 23, 2022

一样的处理手法

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 23, 2022

新拉模版 = 新install, 会安装到enhanced-resolve新的版本, 再锁一下版本就可以了, 等修复了就解除锁定.

@zhuxiaoweb
Copy link
Author

我这样操作的:

  1. yarn add [email protected] -D
  2. yarn dev:h5
    还是报错,是哪里不对吗?
    我园项目package.js的devDep里原本没有enhanced-resolve的。

@yanbowe
Copy link

yanbowe commented Nov 23, 2022

把node_modules和lock文件删除,再install,不然还是有缓存

@zhuxiaoweb
Copy link
Author

  1. enhanced-resolve

我刚才把node_modules和lock文件删除,再install了一次,还是报这个错,
锁版是在package.js里锁吗?
image

@yanbowe
Copy link

yanbowe commented Nov 23, 2022

  1. enhanced-resolve

我刚才把node_modules和lock文件删除,再install了一次,还是报这个错, 锁版是在package.js里锁吗? image

我这边是正常了,你可以试下我的项目

@helloint
Copy link

嗯,锁版后问题解决
"enhanced-resolve": "5.10.0"

@zhuxiaoweb
Copy link
Author

https://github.com/yanbowe/taro-vue3-pinia

嗯 我试了你的项目这样做确实解决了,我用taro-cli拉的nutui模板项目却不行 有点难受

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 23, 2022

https://github.com/yanbowe/taro-vue3-pinia

嗯 我试了你的项目这样做确实解决了,我用taro-cli拉的nutui模板项目却不行 有点难受

你的操作可能不对, 没锁成功.

@hongxuWei
Copy link

webpack/enhanced-resolve#362
新版跟 webpack-virtual-modules 有冲突

@ZakaryCode ZakaryCode added V-3 Version - 3.x F-vue3 Framework - Vue 3 T-h5 Target - 编译到 H5 labels Nov 23, 2022
@zhuxiaoweb
Copy link
Author

https://github.com/yanbowe/taro-vue3-pinia

嗯 我试了你的项目这样做确实解决了,我用taro-cli拉的nutui模板项目却不行 有点难受

你的操作可能不对, 没锁成功.

嗯 我后面再试试看

@geekact
Copy link

geekact commented Nov 23, 2022

yarn的解决方案 package.json

{
  "resolutions": {
    "webpack/enhanced-resolve": "5.10.0",
    "@tarojs/webpack5-runner/@tarojs/webpack5-prebundle/enhanced-resolve": "5.10.0"
  }
}

@zhuxiaoweb
Copy link
Author

yarn的解决方案 package.json

{
  "resolutions": {
    "webpack/enhanced-resolve": "5.10.0",
    "@tarojs/webpack5-runner/@tarojs/webpack5-prebundle/enhanced-resolve": "5.10.0"
  }
}

原来yarn有resolutions可以锁版本,学到了,感谢!

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 24, 2022

[email protected] 已发布.

@yoyo837 yoyo837 closed this as completed Nov 24, 2022
@zhuxiaoweb
Copy link
Author

enhanced-resolve

嗯 我试了下现在不用锁版本也正常了

@crimson968
Copy link

crimson968 commented Nov 29, 2022

enhanced-resolve

嗯 我试了下现在不用锁版本也正常了

还是存在相同的问题,请问后来是怎么解决的

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 29, 2022

删除node_modules, 删除lock文件, reinstall.

@crimson968
Copy link

删除node_modules, 删除lock文件, reinstall.

OK了,是其他依赖包导致的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-vue3 Framework - Vue 3 T-h5 Target - 编译到 H5 upstream 上游bug, 需要上游修复的 V-3 Version - 3.x
Projects
Archived in project
Development

No branches or pull requests

8 participants