[英]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.