React Native:无法构造变压器:错误:无法创建长度超过 0x1fffffe8 个字符的字符串

Mit*_*h K 16 node.js react-native

听到的是错误的屏幕截图

包.json

{
  "name": "project",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.12.0",
    "@react-native-community/clipboard": "^1.2.3",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/drawer": "^5.9.0",
    "@react-navigation/native": "^5.7.3",
    "@react-navigation/stack": "^5.9.0",
    "@twotalltotems/react-native-otp-input": "^1.3.11",
    "jetifier": "^1.6.6",
    "react": "16.13.1",
    "react-native": "^0.63.2",
    "react-native-barcode-builder": "^2.0.0",
    "react-native-biometrics": "^2.1.4",
    "react-native-chart-kit": "^6.6.1",
    "react-native-gesture-handler": "^1.7.0",
    "react-native-image-picker": "^2.3.3",
    "react-native-localization": "^2.1.6",
    "react-native-paper": "^4.0.1",
    "react-native-reanimated": "^1.13.0",
    "react-native-safe-area-context": "^3.1.6",
    "react-native-screens": "^2.10.1",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^12.1.0",
    "react-native-swipe-list-view": "^3.2.3",
    "react-native-vector-icons": "^7.0.0"
  },
  "devDependencies": {
    "@babel/core": "7.11.4",
    "@babel/runtime": "7.11.2",
    "@react-native-community/eslint-config": "1.1.0",
    "babel-jest": "25.5.1",
    "eslint": "6.8.0",
    "jest": "25.5.4",
    "metro-react-native-babel-preset": "0.59.0",
    "miragejs": "^0.1.40",
    "react-test-renderer": "16.13.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

Run Code Online (Sandbox Code Playgroud)

除了这个之外,我没有找到任何与此相关的答案: https: //github.com/facebook/react-native/issues/28189

但这对我不起作用...

myapp成功安装在 Android 模拟器上,但卡在启动屏幕上...

该应用程序在我的办公室计算机上运行良好,但在我自己的计算机上无法运行

我的节点版本v14.10.0

所以请帮助我。

Dom*_*olt 20

我尝试记录导致错误的文件,但 console.log 不起作用。我想出了一个快速破解方法,然后throw filePath我发现我保留作为备份的 zip 文件是问题所在。

由于某种原因,反应不喜欢它,所以我必须将其移到项目文件夹之外


Dir*_*irk 5

对于其他有同样问题并正在寻找调试方法的人:

  • 编辑/node_modules/jest-haste-map/build/worker.js

  • 包裹readFileSync在 a 中try...catch,如下所示:

  const getContent = () => {
    if (content === undefined) {
      try {
        content = fs().readFileSync(filePath, 'utf8');
      } catch (err) {
        throw new Error(`error readFileSync ${filePath} : ${err.message}`);
      }
    }

    return content;
  };
Run Code Online (Sandbox Code Playgroud)
  • (重新)启动 Metro 捆绑程序:

/node_modules/react-native/scripts/launchPackager.command; exit

我的输出:

To reload the app press "r"
To open developer menu press "d"

Failed to construct transformer:  Error: error readFileSync <my project path>/some/big/file/that/caused/error : Cannot create a string longer than 0x1fffffe8 characters
    at getContent (<my project path>/node_modules/jest-haste-map/build/worker.js:133:15)
    at Object.worker (<my project path>/node_modules/jest-haste-map/build/worker.js:162:23)
    at execFunction (<my project path>/node_modules/jest-worker/build/workers/processChild.js:145:17)
    at execHelper (<my project path>/node_modules/jest-worker/build/workers/processChild.js:124:5)
    at execMethod (<my project path>/node_modules/jest-worker/build/workers/processChild.js:128:5)
    at process.messageListener (<my project path>/node_modules/jest-worker/build/workers/processChild.js:46:7)
    at process.emi

Run Code Online (Sandbox Code Playgroud)

希望这可以帮助其他遇到同样问题的人!


dda*_*ett 1

将任何大型资源文件 [图片、视频等] 移出项目目录。 https://github.com/facebook/react-native/issues/28189#issuecomment-592918995