gpt4 book ai didi

ios - 地铁 bundler 错误 : Module `@babel/runtime/helpers/interopRequireDefault` does not exist in the Haste module map

转载 作者:行者123 更新时间:2023-12-05 02:50:32 25 4
gpt4 key购买 nike

尝试通过 xcode (IOS) 和 metrobundler 运行应用程序时,出现此错误

error: bundling failed: Error: Unable to resolve module `@babel/runtime/helpers/interopRequireDefault` from `<rootDir>/index.js`: Module `@babel/runtime/helpers/interopRequireDefault` does not exist in the Haste module map

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.
4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
at ModuleResolver.resolveDependency (<rootDir>/node_modules/@react-native-community/cli/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:183:15)
at ResolutionRequest.resolveDependency (<rootDir>/node_modules/@react-native-community/cli/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
at DependencyGraph.resolveDependency (<rootDir>/node_modules/@react-native-community/cli/node_modules/metro/src/node-haste/DependencyGraph.js:283:16)
at Object.resolve (<rootDir>/node_modules/@react-native-community/cli/node_modules/metro/src/lib/transformHelpers.js:261:42)
at dependencies.map.result (<rootDir>/node_modules/@react-native-community/cli/node_modules/metro/src/DeltaBundler/traverseDependencies.js:399:31)
at Array.map (<anonymous>)
at resolveDependencies (<rootDir>/node_modules/@react-native-community/cli/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:18)
at <rootDir>/node_modules/@react-native-community/cli/node_modules/metro/src/DeltaBundler/traverseDependencies.js:269:33
at Generator.next (<anonymous>)
at asyncGeneratorStep (<rootDir>/node_modules/@react-native-community/cli/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)
BUNDLE [ios, dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.

尝试了以下步骤:


  1. 清除守望者 watch :watchman watch-del-all
  2. 删除 node_modules 文件夹:rm -rf node_modules && npm install
  3. 重置 Metro Bundler 缓存:rm -rf/tmp/metro-bundler-cache-*npm start -- --reset-cache
  4. 删除加速缓存:rm -rf/tmp/haste-map-react-native-packager-*

npm 添加@babel/runtimenpm 安装


卸载守望者


npm 添加@babel/runtime --save-dev


在 .watchmanconfig 中添加了 "ignore_dirs": ["node_modules"]


react-native 启动 --reset-cache


似乎没有任何效果。我被这个错误困住了。这是我的系统信息:

react-native-cli: 2.0.1, react native :0.59.9

守望者--版本 4.9.0

"@babel/runtime": "7.0.0","@babel/cli": "7.5.0","@babel/core": "7.5.4"

已检查文件:@babel/runtime/helpers/interopRequireDefault 存在于给定位置

最佳答案

看起来您的 metro-bundler 没有正确查看文件夹。在构建 RN 库时经历了同样的事情,其中​​ node_modules 文件夹和 package.json 文件与应用程序入口点不在同一级别。尝试将此添加到您的 metro.config.js 文件(如果没有,则在根目录中创建一个新文件):

const path = require('path');

module.exports = {
projectRoot: path.resolve('example'),
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
watchFolders: [path.resolve('node_modules')],
};

example 是你的 rootDir

关于ios - 地铁 bundler 错误 : Module `@babel/runtime/helpers/interopRequireDefault` does not exist in the Haste module map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63644918/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com