javascript 错误:索引,js:[BABEL]:在react-native中找不到模块“node:fs”

rn0zuynd  于 2022-12-21  发布在  Java
关注(0)|答案(1)|浏览(119)

我正在尝试在Andriod上运行React原生应用程序,但我得到这个错误presets: ['module:metro-react-native-babel-preset'],,有人能帮我如何解决这个问题吗?

const {getDefaultConfig} = require('metro-config');
module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
};
module.exports = (async () => {
  const {
    resolver: {sourceExts, assetExts},
  } = await getDefaultConfig();
  return {
    transformer: {
      babelTransformerPath: require.resolve('react-native-svg-transformer'),
    },
    resolver: {
      assetExts: assetExts.filter(ext => ext !== 'svg'),
      sourceExts: [...sourceExts, 'svg'],
    },
  };
})();
bweufnob

bweufnob1#

1.请检查metro-react-native-babel-preset依赖项是否安装在您的package.json文件中。
如果没有,请使用以下命令安装:第一个月
1.请检查babel.config.js文件
应该有这样的代码:

module.exports = {

 presets: ['module:metro-react-native-babel-preset'],

 ....

}

相关问题