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

【h5端】taro-h5中导入Taro的node_modules路径解析错误 #9478

Closed
Saifa-96 opened this issue Jun 8, 2021 · 6 comments
Closed

【h5端】taro-h5中导入Taro的node_modules路径解析错误 #9478

Saifa-96 opened this issue Jun 8, 2021 · 6 comments
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x

Comments

@Saifa-96
Copy link

Saifa-96 commented Jun 8, 2021

相关平台

H5

浏览器版本: Google Chrome 版本 91.0.4472.77(正式版本) (arm64)
使用框架: React

复现步骤

yarn dev:h5 无法正常启动项目
报错提示:

index.js?c00c:75 Uncaught TypeError: getInitPxTransform is not a function
    at eval (index.js?c00c:75)
    at Module../node_modules/@tarojs/taro-h5/src/taro/index.js (app.js:1928)
    at __webpack_require__ (app.js:836)
    at fn (app.js:130)
    at eval (index.js?1c5f:1)
    at Module../node_modules/@tarojs/taro-h5/src/index.js (app.js:1916)
    at __webpack_require__ (app.js:836)
    at fn (app.js:130)
    at eval (h5.js?ad6f:1)
    at Module../node_modules/@tarojs/taro/h5.js (app.js:1940)

期望结果

h5端正常启动

实际结果

找不到 getInitPxTransform

环境信息

👽 Taro v3.2.9


  Taro CLI 3.2.9 environment info:
    System:
      OS: macOS 11.2.3
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 14.7.0 - ~/.nvm/versions/node/v14.7.0/bin/node
      Yarn: 1.22.10 - ~/.nvm/versions/node/v14.7.0/bin/yarn
      npm: 6.14.7 - ~/.nvm/versions/node/v14.7.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.2.9 => 3.2.9 
      @tarojs/components: 3.2.9 => 3.2.9 
      @tarojs/mini-runner: 3.2.9 => 3.2.9 
      @tarojs/react: 3.2.9 => 3.2.9 
      @tarojs/runtime: 3.2.9 => 3.2.9 
      @tarojs/taro: 3.2.9 => 3.2.9 
      @tarojs/webpack-runner: 3.2.9 => 3.2.9 
      babel-preset-taro: 3.2.9 => 3.2.9 
      eslint-config-taro: 3.2.9 => 3.2.9 
      react: 17.0.2 => 17.0.2 
      react-native: 0.64.0 => 0.64.0 
      taro-ui: 3.0.0-alpha.10 => 3.0.0-alpha.10 

补充信息

修改import语句后能正常运行

// 文件路径:node_modules/@tarojs/taro-h5/src/taro/index.js

// import Taro from '@tarojs/api'
// 手动修改Taro引入路径就能正常运行
import Taro from '../../node_modules/@tarojs/api'
import { history, navigateBack, navigateTo, createRouter, reLaunch, redirectTo, getCurrentPages, switchTab } from '@tarojs/router'
import { permanentlyNotSupport } from '../api/utils'
@taro-bot2 taro-bot2 bot added F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Jun 8, 2021
@Chen-jj
Copy link
Contributor

Chen-jj commented Jun 8, 2021

试试 3.2.10

@Saifa-96
Copy link
Author

Saifa-96 commented Jun 8, 2021

试试 3.2.10
@Chen-jj 更新后正常了,谢谢

@zzzhan
Copy link

zzzhan commented Jun 9, 2021

试试 3.2.10

已升级最新的3.2.10,还是有这个问题 @luckyadam

👽 Taro v3.2.10

Taro CLI 3.2.10 environment info:
System:
OS: macOS 11.2.3
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.14.11 - ~/.nvm/versions/node/v14.16.0/bin/npm
npmPackages:
@tarojs/components: 3.2.10 => 3.2.10
@tarojs/mini-runner: 3.2.10 => 3.2.10
@tarojs/react: 3.2.10 => 3.2.10
@tarojs/runtime: 3.2.10 => 3.2.10
@tarojs/taro: 3.2.10 => 3.2.10
@tarojs/webpack-runner: 3.2.10 => 3.2.10
babel-preset-taro: 3.2.10 => 3.2.10
eslint-config-taro: 3.2.10 => 3.2.10
react: ^17.0.0 => 17.0.2
taro-ui: 3.0.0-alpha.10 => 3.0.0-alpha.10

yarn dev:h5 无法正常启动项目
报错提示:

TypeError
getInitPxTransform is not a function
Call Stack
 undefined
  node_modules/@tarojs/taro-h5/src/taro/index.js:121:41
 ./node_modules/
  taro-h5/src/taro/index.js@http://10.18.30.148:10086/js/app.js:2372:1
webpack_require
  app.js:836:31
 fn
  app.js:130:20
 undefined
  node_modules/@tarojs/taro-h5/src/index.js:2:88
 ./node_modules/
  taro-h5/src/index.js@http://10.18.30.148:10086/js/app.js:2360:1
webpack_require
  app.js:836:31
 fn
  app.js:130:20
 undefined
  node_modules/@tarojs/taro/h5.js:2:92
 ./node_modules/
  taro/h5.js@http://10.18.30.148:10086/js/app.js:2384:1

@zzzhan
Copy link

zzzhan commented Jun 9, 2021

import Taro from '../../node_modules/@tarojs/api'
@Saifa-96 你确定这个问题解决了吗?目前暂时按你补充的信息修改就好了

@mindfocus
Copy link
Contributor

3.3.9 h5+vue 出现同样问题,手动修改Taro引入路径就能正常运行

Taro CLI 3.3.9 environment info:
System:
OS: Windows 10
Binaries:
Node: 12.22.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.15 - C:\Program Files\nodejs\yarn.CMD
npm: 6.14.12 - C:\Program Files\nodejs\npm.CMD

@helloint
Copy link

Taro v3.3.20 碰到同样报错。(项目是从Taro 3.4.13降级到3.3.20,为了尝试echarts-taro3-react

👽 Taro v3.3.20


  Taro CLI 3.3.20 environment info:
    System:
      OS: macOS 12.4
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 12.22.12 - ~/.nvm/versions/node/v12.22.12/bin/node
      Yarn: 1.22.17 - /opt/homebrew/bin/yarn
      npm: 6.14.16 - ~/.nvm/versions/node/v12.22.12/bin/npm
    npmPackages:
      @tarojs/cli: 3.3.20 => 3.3.20 
      @tarojs/components: 3.3.20 => 3.3.20 
      @tarojs/mini-runner: 3.3.20 => 3.3.20 
      @tarojs/react: 3.3.20 => 3.3.20 
      @tarojs/runtime: 3.3.20 => 3.3.20 
      @tarojs/taro: 3.3.20 => 3.3.20 
      @tarojs/webpack-runner: 3.3.20 => 3.3.20 
      babel-preset-taro: 3.3.20 => 3.3.20 
      eslint-config-taro: 3.3.20 => 3.3.20 
      react: ^17.0.2 => 17.0.2 
      react-native: ^0.67.3 => 0.67.4 

确认CLI和project版本一致,并且删除了node_modules和lockfile重新安装了依赖,问题仍然存在。
也是手动修改Taro引入路径就能正常运行。

@ZakaryCode ZakaryCode moved this to Done in H5 Apr 10, 2023
@ZakaryCode ZakaryCode added this to H5 Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Archived in project
Development

No branches or pull requests

6 participants