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 ui无法安装最新版3.3.0 #1803

Open
djx0716 opened this issue Jun 19, 2024 · 3 comments
Open

taro ui无法安装最新版3.3.0 #1803

djx0716 opened this issue Jun 19, 2024 · 3 comments

Comments

@djx0716
Copy link

djx0716 commented Jun 19, 2024

问题描述
通过taro-cli拉去的最新taro-ui模板,在执行npm-install时会遇到报错(报错日志在后面),经过我查询issues时发现降级taro-ui到3.1.0-beta.4可以解决该问题。
今天开发项目时遇到一个问题:taro-ui 3.1.0-beta.4无法渲染AtForm。按照Issue:1726排查问题后,依然无法解决。设置Compiler prebundle后微信开发程序调试器会报错(报错日志在后面)。或者引入scss也无法渲染AtForm内容。
查询issues后发现需要升级到taro-ui@latest,也就是taro-ui 3.3.0。但是升级后执行npm install会报错(报错日志与拉取模板相同)

复现步骤

import 'taro-ui/dist/style/components/form.scss'

import { Component, PropsWithChildren } from 'react'
import { View } from '@tarojs/components'
import { AtButton, AtForm, AtInput } from 'taro-ui'

export default class Index extends Component<PropsWithChildren, { value: string }> {
	constructor(props: PropsWithChildren) {
		super(props)
		this.state = {
			value: '',
		}
	}

	handleChange(value) {
		this.setState({
			value,
		})
	}

	onSubmit() {
		console.log(this.state.value)
	}

	onReset() {
		this.setState({
			value: '',
		})
	}

	render() {
		return (
			<View className='index'>
				<AtForm onSubmit={this.onSubmit.bind(this)} onReset={this.onReset.bind(this)}>
					<AtInput
						name='value'
						title='文本'
						type='text'
						placeholder='单行文本'
						value={this.state.value}
						onChange={this.handleChange.bind(this, 'value')}
					/>
					<AtButton formType='submit'>提交</AtButton>
					<AtButton formType='reset'>重置</AtButton>
				</AtForm>
			</View>
		)
	}
}

期望行为

期望能够正确渲染AtForm,以及能够升级到taro-ui@3.3.0

报错信息

  1. npm install taro-ui@latest

npm resolution error report
While resolving: myApp@1.0.0
Found: react@18.3.1
node_modules/react
react@"^18.0.0" from the root project
peer react@">=16.13.0" from taro-ui@3.3.0
node_modules/taro-ui
taro-ui@"^3.2.1" from the root project
peer react@"^18.3.1" from react-dom@18.3.1
node_modules/react-dom
react-dom@"^18.0.0" from the root project
peer react-dom@">=16.13.0" from taro-ui@3.3.0
node_modules/taro-ui
taro-ui@"^3.2.1" from the root project

Could not resolve dependency:
peer react@"18.2.0" from react-native@0.74.2
node_modules/react-native
peer react-native@">=0.62.0" from taro-ui@3.3.0
node_modules/taro-ui
taro-ui@"^3.2.1" from the root project

Fix the upstream dependency conflict, or retry
this command with --force or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

  1. 修改config prebundle后微信开发者工具调试器报错
    TypeError: webpack_modules[moduleId] is not a function
    at webpack_require (webpack_bootstrap:19)
    at Object../node_modules/@tarojs/taro-loader/lib/entry-cache.js?name=pages/today/index!./src/pages/today/index.tsx (index.js:32)
    at webpack_require (webpack_bootstrap:19)
    at Object../src/pages/today/index.tsx (index.tsx?a088:181)
    at webpack_require (webpack_bootstrap:19)
    at webpack_exec (._src_requests_today.ts:33)
    at ._src_requests_today.ts:33
    at Function.webpack_require.O (webpack_runtime_chunk loaded:25)
    at ._src_requests_today.ts:33
    at webpackJsonpCallback (webpack_runtime_jsonp chunk loading:73)(env: Windows,mp,1.06.2405010; lib: 3.4.6)

系统信息

👽 Taro v3.6.31

Taro CLI 3.6.31 environment info:
System:
OS: Windows 11 10.0.22631
Binaries:
Node: 22.3.0 - C:\Program Files\nodejs\node.EXE
npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
npmPackages:
@tarojs/cli: 3.6.31 => 3.6.31
@tarojs/components: 3.6.31 => 3.6.31
@tarojs/helper: 3.6.31 => 3.6.31
@tarojs/plugin-framework-react: 3.6.31 => 3.6.31
@tarojs/plugin-platform-alipay: 3.6.31 => 3.6.31
@tarojs/plugin-platform-h5: 3.6.31 => 3.6.31
@tarojs/plugin-platform-jd: 3.6.31 => 3.6.31
@tarojs/plugin-platform-qq: 3.6.31 => 3.6.31
@tarojs/plugin-platform-swan: 3.6.31 => 3.6.31
@tarojs/plugin-platform-tt: 3.6.31 => 3.6.31
@tarojs/plugin-platform-weapp: 3.6.31 => 3.6.31
@tarojs/react: 3.6.31 => 3.6.31
@tarojs/runtime: 3.6.31 => 3.6.31
@tarojs/shared: 3.6.31 => 3.6.31
@tarojs/taro: 3.6.31 => 3.6.31
@tarojs/taro-loader: 3.6.31 => 3.6.31
@tarojs/webpack5-runner: 3.6.31 => 3.6.31
babel-preset-taro: 3.6.31 => 3.6.31
eslint-config-taro: 3.6.31 => 3.6.31
react: ^18.0.0 => 18.3.1
taro-ui: ^3.1.0-beta.4 => 3.1.0-beta.4

补充信息

Copy link

taro-ui-bot bot commented Jun 19, 2024

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@djx0716
Copy link
Author

djx0716 commented Jun 19, 2024

又尝试了一会儿,发现删除项目目录下的dist文件夹,再修改config.ts到

compiler: {
		type: 'webpack5',
		prebundle: {
			exclude: ['taro-ui'],
		},
	},

通过@import '~taro-ui/dist/style/index.scss'; 可以正确渲染AtForm。
然而按需引入@import '~taro-ui/dist/style/components/form.scss';无法渲染AtForm。
依然无法升级taro-ui到最新版本3.3.0

@djx0716 djx0716 changed the title taro ui无法安装最新版3.3.0,与taro-ui 3.1.0-beta.4无法渲染AtForm taro ui无法安装最新版3.3.0 Jun 19, 2024
@simline
Copy link

simline commented Jun 26, 2024

npm package with wrong react-dom version, but at release files is fine, anyone will fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants