Metro遇到了一个错误:尝试解析模块时“ IDB-Keyval'从文件

发布于 2025-02-11 22:12:13 字数 1277 浏览 1 评论 0原文

尝试连接到以下文档的REECT本机中的数据库(Back4App): https://www.back4app.com/docs/react-native/parse-sdk/react-native-sdk 我获得了此错误消息:

尝试从文件/users/chenhana/Chenhana/testregistration/node_modules/parse/parse/parse/parse/rib/react-native/indexeddbstoragecontroller.js IDB-Keyval >,成功找到了软件包/users/chenhana/testregistration/node_modules/idb-keyval/package.json。但是,此软件包本身指定无法解决的main模块字段(/users/chenhana/testregistration/node_modules/idb-keyval/dist/dist/compat.cjs。的确。 ,这些文件都不存在:

  • /users/chenhana/testregistration/node_modules/idb-keyval/dist/compat.cjs(comp.nativeM.Ios.ios.ts| native.native.ts| ts| ts| ts|.ios.ios.tsx|。 tsx | .tsx | ..ios.js | .native.js | .js | .js.ios.jsx | .native.jsx | .jsx | .jsx | .ios.json | .native.json | .json | .json)
  • /users/users/chenhana/testregistration /node_modules/idb-keyval/dist/compat.cjs/index(.native |。本机| .js | .js | .ios.jsx | .native.jsx | .jsx | ..ios.json | .native.json | .json | .json)

尝试重置缓存,删除和重新安装NPM模块,然后与Doc(一起)(还安装了Parse JavaScript SDK),所以我不太确定为什么会出现任何帮助。

Trying to connect to a database (back4app) in React Native following this doc: https://www.back4app.com/docs/react-native/parse-sdk/react-native-sdk
I was given this error message:

While trying to resolve module idb-keyval from file /Users/chenhana/TestRegistration/node_modules/parse/lib/react-native/IndexedDBStorageController.js, the package /Users/chenhana/TestRegistration/node_modules/idb-keyval/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/Users/chenhana/TestRegistration/node_modules/idb-keyval/dist/compat.cjs. Indeed, none of these files exist:

  • /Users/chenhana/TestRegistration/node_modules/idb-keyval/dist/compat.cjs(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
  • /Users/chenhana/TestRegistration/node_modules/idb-keyval/dist/compat.cjs/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)

Tried resetting cache, deleting and reinstalling npm modules, and followed along with the doc (also installed the Parse Javascript SDK) so I'm not too sure why this error keeps coming up. Any help will be appreciated, thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怎会甘心 2025-02-18 22:12:13

在您的Metro.conf.js文件中,放置以下代码:

const { getDefaultConfig } = require("@expo/metro-config");
const defaultConfig = getDefaultConfig(__dirname);
defaultConfig.resolver.assetExts.push("cjs");
module.exports = defaultConfig;

它可能会解决问题

In your metro.conf.js file, put the following code:

const { getDefaultConfig } = require("@expo/metro-config");
const defaultConfig = getDefaultConfig(__dirname);
defaultConfig.resolver.assetExts.push("cjs");
module.exports = defaultConfig;

It might solve the issue

始终不够 2025-02-18 22:12:13

为此,更改您的Metro.config.js

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */
const defaultSourceExts =
  require('metro-config/src/defaults/defaults').sourceExts;
module.exports = {
  transformer: {
    getTransformOptions: () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
  resolver: {
    sourceExts: process.env.RN_SRC_EXT
      ? [...process.env.RN_SRC_EXT.split(',').concat(defaultSourceExts), 'cjs'] // <-- cjs added here
      : [...defaultSourceExts, 'cjs'], // <-- cjs added here
  },
};

Change your metro.config.js for this:

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */
const defaultSourceExts =
  require('metro-config/src/defaults/defaults').sourceExts;
module.exports = {
  transformer: {
    getTransformOptions: () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
  resolver: {
    sourceExts: process.env.RN_SRC_EXT
      ? [...process.env.RN_SRC_EXT.split(',').concat(defaultSourceExts), 'cjs'] // <-- cjs added here
      : [...defaultSourceExts, 'cjs'], // <-- cjs added here
  },
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文