无法在 Bundler.transformFile 读取未定义的属性(读取“transformFile”)

新手上路,请多包涵

我今天更新了 node ,我收到了这个错误:

 error: TypeError: Cannot read properties of undefined (reading 'transformFile')
    at Bundler.transformFile (/Users/.../node_modules/metro/src/Bundler.js:48:30)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.transform (/Users/.../node_modules/metro/src/lib/transformHelpers.js:101:12)
    at async processModule (/Users/.../node_modules/metro/src/DeltaBundler/traverseDependencies.js:137:18)
    at async traverseDependenciesForSingleFile (/Users/.../node_modules/metro/src/DeltaBundler/traverseDependencies.js:131:3)
    at async Promise.all (index 0)
    at async initialTraverseDependencies (/Users/.../node_modules/metro/src/DeltaBundler/traverseDependencies.js:114:3)
    at async DeltaCalculator._getChangedDependencies (/Users/.../node_modules/metro/src/DeltaBundler/DeltaCalculator.js:164:25)
    at async DeltaCalculator.getDelta (/Users/.../node_modules/metro/src/DeltaBundler/DeltaCalculator.js:94:16)

除此之外,我没有做任何不寻常的事情,所以我不确定要分享什么。如果我缺少任何信息,请发表评论,我会添加它。

在构建终端时也会引发此错误:

 Failed to construct transformer:  Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at stableHash (/Users/.../node_modules/metro-cache/src/stableHash.js:19:8)
    at Object.getCacheKey (/Users/.../node_modules/metro-transform-worker/src/index.js:593:7)
    at getTransformCacheKey (/Users/.../node_modules/metro/src/DeltaBundler/getTransformCacheKey.js:24:19)
    at new Transformer (/Users/.../node_modules/metro/src/DeltaBundler/Transformer.js:48:9)
    at /Users/.../node_modules/metro/src/Bundler.js:22:29
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

我的节点、npx 和 react-native 版本是:

  • 节点:17.0.0
  • npx:8.1.0
  • 反应原生 cli:2.0.1

原文由 Chaudhry Talha 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.8k
2 个回答

在 Node.js 17.0.0 中遇到了同样的问题。为了解决这个问题,我降级到版本 14.18.1,删除 node_modules 并重新安装。

原文由 memoalv 发布,翻译遵循 CC BY-SA 4.0 许可协议

您可以通过降级节点js来解决它

> nvm list // to see all available node version

> nvm install 16.13.0 // to install the version I wanted

> nvm use 16.13.0  // use the installed version
OR
> nvm alias default 16 // use the installed version as DEFAULT

原文由 uzai sindiko 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题