Expo>React Nativeで、firebase@9.0.5にアップデートしたときに、idbファイルが見つけられないエラーが出た。
While trying to resolve module
idb
from file~/node_modules/@firebase/app/dist/esm/index.esm2017.js
, the package~/node_modules/idb/package.json
was successfully found. However, this package itself specifies amain
module field that could not be resolved (~/node_modules/idb/build/index.cjs
. Indeed, none of these files exist:
解決方法
ルートディレクトリにmetro.config.jsファイルを作成して、手動で.cjsをパースする設定を追加metro.config.js
const { getDefaultConfig } = require("expo/metro-config");
const config = getDefaultConfig(__dirname);
config.resolver.assetExts.push("cjs");
module.exports = config;
参考
Metro Bundler