简体   繁体   English

错误:[BABEL]:在 react-native-builder-bob 中找不到模块“./built-in-definitions”

[英]Error: [BABEL]: Cannot find module './built-in-definitions' in react-native-builder-bob

when I run the command to build the react-native library:当我运行命令构建 react-native 库时:

yarn prepare

show error:显示错误:

yarn run v1.22.19
$ bob build
ℹ Building target commonjs
ℹ Cleaning up previous build at lib/commonjs
ℹ Compiling 1 files in src with babel
bob build

build files for publishing

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]

Error: [BABEL]: Cannot find module './built-in-definitions'
Require stack:
- /Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/babel-plugin-polyfill-corejs2/lib/index.js
- /Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/@babel/preset-env/lib/index.js
- /Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/@babel/core/lib/config/files/module-types.js
- /Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/@babel/core/lib/config/files/configuration.js
- /Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/@babel/core/lib/config/files/index.js
- /Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/@babel/core/lib/index.js
- /Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/react-native-builder-bob/lib/utils/compile.js
- /Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/react-native-builder-bob/lib/targets/commonjs.js
- /Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/react-native-builder-bob/lib/index.js
- /Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/react-native-builder-bob/bin/bob (While processing: /Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/@babel/preset-env/lib/index.js)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/babel-plugin-polyfill-corejs2/lib/index.js:8:27)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/@babel/preset-env/lib/index.js:32:34)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/babel-plugin-polyfill-corejs2/lib/index.js',
    '/Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/@babel/preset-env/lib/index.js',
    '/Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/@babel/core/lib/config/files/module-types.js',
    '/Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/@babel/core/lib/config/files/configuration.js',
    '/Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/@babel/core/lib/config/files/index.js',
    '/Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/@babel/core/lib/index.js',
    '/Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/react-native-builder-bob/lib/utils/compile.js',
    '/Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/react-native-builder-bob/lib/targets/commonjs.js',
    '/Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/react-native-builder-bob/lib/index.js',
    '/Users/ibrahimtahayna/Desktop/react-native-awesome-library/node_modules/react-native-builder-bob/bin/bob'
  ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

why did this error happen?为什么会发生这个错误? what should I do to fix this problem?我应该怎么做才能解决这个问题? I have already tried to remove node-module and yarn.lock.我已经尝试删除 node-module 和 yarn.lock。 Also when create new project still happening and I try to update react-native-builder-bob.此外,当创建新项目仍在发生时,我尝试更新 react-native-builder-bob。

Did you follow the 'Automatic configuration' or 'Manual configuration' steps as described in the documentation?您是否按照文档中所述的“自动配置”或“手动配置”步骤进行操作? https://github.com/callstack/react-native-builder-bob#automatic-configuration https://github.com/callstack/react-native-builder-bob#automatic-configuration

It seems like Babel is not configured correctly.似乎 Babel 配置不正确。 It can not find the built-in-definitions.ts file from the babel-polyfills package, which can be found here.它无法从babel-polyfills polyfills package 中找到built-in-definitions.ts文件,可以在这里找到。 https://github.com/babel/babel-polyfills/tree/main/packages/babel-plugin-polyfill-corejs2/src https://github.com/babel/babel-polyfills/tree/main/packages/babel-plugin-polyfill-corejs2/src

I think Babel will be set-up correctly after finishing the configuration steps.我认为在完成配置步骤后,Babel 将被正确设置。

Edit: Or did you configure your package using the commonjs build-target during setup?编辑:或者您是否在设置期间使用commonjs构建目标配置了 package? If you want to build a react-native package you should choose the module option.如果你想构建一个 react-native package 你应该选择module选项。 commonjs is used for Node environments, and React-native uses Metro. commonjs用于 Node 环境,React-native 使用 Metro。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 BABEL 找不到模块“节点:路径”错误 react-native - BABEL Cannot find module 'node:path' error react-native React Native Typescript babel-plugin-module-resolver 错误:找不到模块或其对应的类型声明 - React Native Typescript babel-plugin-module-resolver error: Cannot find module or its corresponding type declerations 捆绑失败:错误:无法从&#39;/ workspace / reactnative找到模块&#39;babel-preset-react-native&#39; - bundling failed: Error: Cannot find module 'babel-preset-react-native' from '/workspace/reactnative'' 错误:index.js: [BABEL]: 在 react-native 中找不到模块 'node:fs' - error: index.js: [BABEL]: Cannot find module 'node:fs' in react-native Gulp和Babel:错误:找不到模块 - Gulp and Babel: Error: Cannot find module React Native 无法 npx init 项目,找不到模块错误 - React Native cannot npx init project, cannot find module error 错误:找不到模块“ reative-native” /未找到模块:错误:无法解析模块“ react-native-web” - Error: Cannot find module “react-native” / Module not found: Error: Cannot resolve module 'react-native-web' 加载React Native:UnhandledPromiseRejectionWarning:错误:找不到模块&#39;View&#39; - Loading React Native: UnhandledPromiseRejectionWarning: Error: Cannot find module 'View' 模块构建失败:错误:找不到模块'@ babel / core' - Module build failed: Error: Cannot find module '@babel/core' ERROR in找不到模块'babel-core'。使用react.js,webpack和express服务器 - ERROR in Cannot find module 'babel-core'. using react.js, webpack, and express server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM