Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Error: Cannot find module 'metro-cache' when initiating the new ignite projectΒ #2670

@naoyamakino

Description

@naoyamakino

Describe the bug

Thank you Infinite Red for this amazing work πŸ’―

Here are steps I took to get started.

 npx ignite-cli@latest new PizzaApp --yes





                                               .;;,.    .clll.
                                              .clll,    ,llll.           ...
                                               .,;,.    ;lllc'.,.   .';cllllc,
     .',,.                           ...      .'',,. .:lllllllll. .;lllc:;clll,
    .llll,                    .,...;cllll:.   ,llll, .llllllc,,'  clll:'.,cllc.
    ,llll'       ......;::.  'llcclllllllll'  ,llll,   .llll.    ,lllllllll:'
    ,llll.    .;clllllclll.  'llllc,..,llll,  :llll.   'llll.    ,lllc,''..
    ;llll.   :llllc:cllllc.  ,llll.   .llll, .lllll.   ,lllc...  ,lll:...';:.
   .llllc.  ;lll;.   :lll,   ;lll;    'llll, .llllc.   ,llllcll' .:lllllllll,
   .llll,  'lll:    .clll,   :lll,    ,llll. 'llll,    'lllllcc'   ';::::;'.
   .llll,  ,lll:    .llll'  .llll,    ;llll. ,llll,     .....             .',..
   ,llll.  'llll:,,:cllll.  .lllc.    .''..  ... ....',;         ..',,:::;'..
   ,llll.   'clllllllllll.     .....        ..,::cllllc.   .',:clllc;,'.
   :llll.     ',;,'.;lllc...,;:clll;  ..',:cllllllllll:,;clllllc;,'.
   llll:        ...'cllllllllllllll::cllllllc;,',cllllllllc;'..
   llll,   ..,clllllllll::,,.,lllllllc:,'...    :lllllc,..
   c:;,.  .cllllc:;:llll.    ,ll:;,..          ;ll:,..
          :lll,.  .clll,     ..               .,..
          :lll:,,cllll,
          .cllllllllc'
           .'cllll:.



    β–ˆ Creating PizzaApp using Ignite 9.6.3
    β–ˆ Powered by  ∞ Infinite Red  (https://infinite.red)
    β–ˆ Package Manager: yarn
    β–ˆ Bundle identifier: com.pizzaapp
    β–ˆ Path: /Users/naoyamakino/git/PizzaApp
    ────────────────────────────────────────────────────

    πŸ–¨  3D-printing a new React Native app
    🎨 Getting those last few details perfect
    🧢 Installing yarn dependencies (wow these are heavy)
       Configuring app.json
    πŸ› οΈ  Removing fancy demo markup
    πŸ—„  Backing everything up in source control

    ────────────────────────────────────────────────────

    Ignited PizzaApp in 15.71s  πŸš€

    For next time: here are the Ignite options you picked!
      npx ignite-cli new PizzaApp \
        --bundle=com.pizzaapp \
        --git \
        --install-deps \
        --overwrite=false \
        --packager=yarn \
        --target-path=/Users/naoyamakino/git/PizzaApp \
        --remove-demo=false \
        --workflow=expo \
        --no-timeout=false

    ────────────────────────────────────────────────────

    Need additional help?

    Join our Slack community at http://community.infinite.red.

    ────────────────────────────────────────────────────

    Now get cooking! 🍽
      cd /Users/naoyamakino/git/PizzaApp
      yarn ios
    Or Android via
      yarn android

succeed πŸ‘ then

 cd PizzaApp; yarn ios
Starting project at /Users/naoyamakino/git/PizzaApp
Error: expo-localization tried to access @expo/config-plugins, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: @expo/config-plugins (via "@expo/config-plugins/build/android/Manifest")
Required by: expo-localization@virtual:c8e0c5b5ac0440e31d4ad667e0f0b6e78a7ec8d74de0e3d7282ee58a08367049ebf8e525d7001fa51e13a238833e05080cbd82d36e7fb653a26dddb1e1d9de7f#npm:14.8.4 (via /Users/naoyamakino/git/PizzaApp/.yarn/__virtual__/expo-localization-virtual-95d36c78a2/3/.yarn/berry/cache/expo-localization-npm-14.8.4-7f4d6b02fc-10c0.zip/node_modules/expo-localization/plugin/build/)

Require stack:
- /Users/naoyamakino/git/PizzaApp/.yarn/__virtual__/expo-localization-virtual-95d36c78a2/3/.yarn/berry/cache/expo-localization-npm-14.8.4-7f4d6b02fc-10c0.zip/node_modules/expo-localization/plugin/build/withExpoLocalization.js
- /Users/naoyamakino/git/PizzaApp/.yarn/__virtual__/expo-localization-virtual-95d36c78a2/3/.yarn/berry/cache/expo-localization-npm-14.8.4-7f4d6b02fc-10c0.zip/node_modules/expo-localization/app.plugin.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config-plugins/build/utils/plugin-resolver.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config-plugins/build/plugins/withStaticPlugin.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config-plugins/build/plugins/withPlugins.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config-plugins/build/index.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config/build/plugins/withConfigPlugins.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config/build/Config.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config/build/index.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/utils/analytics/getDevClientProperties.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/resolveOptions.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/index.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/bin/cli
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/expo/bin/cli
Error: expo-localization tried to access @expo/config-plugins, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: @expo/config-plugins (via "@expo/config-plugins/build/android/Manifest")
Required by: expo-localization@virtual:c8e0c5b5ac0440e31d4ad667e0f0b6e78a7ec8d74de0e3d7282ee58a08367049ebf8e525d7001fa51e13a238833e05080cbd82d36e7fb653a26dddb1e1d9de7f#npm:14.8.4 (via /Users/naoyamakino/git/PizzaApp/.yarn/__virtual__/expo-localization-virtual-95d36c78a2/3/.yarn/berry/cache/expo-localization-npm-14.8.4-7f4d6b02fc-10c0.zip/node_modules/expo-localization/plugin/build/)

Require stack:
- /Users/naoyamakino/git/PizzaApp/.yarn/__virtual__/expo-localization-virtual-95d36c78a2/3/.yarn/berry/cache/expo-localization-npm-14.8.4-7f4d6b02fc-10c0.zip/node_modules/expo-localization/plugin/build/withExpoLocalization.js
- /Users/naoyamakino/git/PizzaApp/.yarn/__virtual__/expo-localization-virtual-95d36c78a2/3/.yarn/berry/cache/expo-localization-npm-14.8.4-7f4d6b02fc-10c0.zip/node_modules/expo-localization/app.plugin.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config-plugins/build/utils/plugin-resolver.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config-plugins/build/plugins/withStaticPlugin.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config-plugins/build/plugins/withPlugins.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config-plugins/build/index.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config/build/plugins/withConfigPlugins.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config/build/Config.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/config/build/index.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/utils/analytics/getDevClientProperties.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/resolveOptions.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/index.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/bin/cli
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/expo/bin/cli
    at Function.require$$0.Module._resolveFilename (/Users/naoyamakino/git/PizzaApp/.pnp.cjs:24517:13)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/Users/naoyamakino/.yarn/berry/cache/@cspotcode-source-map-support-npm-0.8.1-964f2de99d-10c0.zip/node_modules/@cspotcode/source-map-support/source-map-support.js:811:30)
    at Function.Module._load (node:internal/modules/cjs/loader:985:27)
    at Function.require$$0.Module._load (/Users/naoyamakino/git/PizzaApp/.pnp.cjs:24408:31)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/Users/naoyamakino/git/PizzaApp/.yarn/__virtual__/expo-localization-virtual-95d36c78a2/3/.yarn/berry/cache/expo-localization-npm-14.8.4-7f4d6b02fc-10c0.zip/node_modules/expo-localization/plugin/build/withExpoLocalization.js:3:20)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at require$$0.Module._extensions..js (/Users/naoyamakino/git/PizzaApp/.pnp.cjs:24560:33)

I added the following change in the package.json

diff --git a/package.json b/package.json
index 8071ba9..0773d41 100644
--- a/package.json
+++ b/package.json
@@ -31,6 +31,7 @@
   },
   "dependencies": {
     "@expo-google-fonts/space-grotesk": "^0.2.2",
+    "@expo/config-plugins": "^6.0.0",
     "@expo/metro-runtime": "~3.1.3",
     "@react-native-async-storage/async-storage": "1.21.0",
     "@react-navigation/bottom-tabs": "^6.3.2",
@@ -48,6 +49,7 @@

with that, when I run yarn ios

 yarn ios
Starting project at /Users/naoyamakino/git/PizzaApp
Error: Cannot find module 'metro-cache'
Require stack:
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/metro-config/build/ExpoMetroConfig.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/serverLogLikeMetro.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/getStaticRenderFunctions.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/metro/metroErrorInterface.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/metro/bundleApiRoutes.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/metro/MetroBundlerDevServer.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/DevServerManager.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/startAsync.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/index.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/bin/cli
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/expo/bin/cli
Require stack:
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/metro-config/build/ExpoMetroConfig.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/serverLogLikeMetro.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/getStaticRenderFunctions.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/metro/metroErrorInterface.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/metro/bundleApiRoutes.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/metro/MetroBundlerDevServer.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/DevServerManager.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/startAsync.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/index.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/bin/cli
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/expo/bin/cli
Error: Cannot find module 'metro-cache'
Require stack:
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/metro-config/build/ExpoMetroConfig.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/serverLogLikeMetro.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/getStaticRenderFunctions.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/metro/metroErrorInterface.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/metro/bundleApiRoutes.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/metro/MetroBundlerDevServer.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/DevServerManager.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/startAsync.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/index.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/bin/cli
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/expo/bin/cli
Require stack:
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/metro-config/build/ExpoMetroConfig.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/serverLogLikeMetro.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/getStaticRenderFunctions.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/metro/metroErrorInterface.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/metro/bundleApiRoutes.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/metro/MetroBundlerDevServer.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/server/DevServerManager.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/startAsync.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/src/start/index.js
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/cli/build/bin/cli
- /Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/expo/bin/cli
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Function.require$$0.Module._resolveFilename (/Users/naoyamakino/git/PizzaApp/.pnp.cjs:24556:54)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/Users/naoyamakino/.yarn/berry/cache/@cspotcode-source-map-support-npm-0.8.1-964f2de99d-10c0.zip/node_modules/@cspotcode/source-map-support/source-map-support.js:811:30)
    at Function.Module._load (node:internal/modules/cjs/loader:985:27)
    at Function.require$$0.Module._load (/Users/naoyamakino/git/PizzaApp/.pnp.cjs:24470:31)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/Users/naoyamakino/.npm/_npx/249ca9fcd30c476a/node_modules/@expo/metro-config/src/ExpoMetroConfig.ts:8:1)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)

then I've installed metro-cache the following

βœ— yarn add metro-cache
➀ YN0000: · Yarn 4.1.1
➀ YN0000: β”Œ Resolution step
➀ YN0000: β”” Completed in 0s 219ms
➀ YN0000: β”Œ Post-resolution validation
➀ YN0002: β”‚ pizza-app@workspace:. doesn't provide @types/node (p500be), requested by ts-node.
➀ YN0086: β”‚ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code.
➀ YN0000: β”” Completed
➀ YN0000: β”Œ Fetch step
➀ YN0000: β”” Completed in 0s 947ms
➀ YN0000: β”Œ Link step
➀ YN0000: β”‚ ESM support for PnP uses the experimental loader API and is therefore experimental
➀ YN0008: β”‚ pizza-app@workspace:. must be rebuilt because its dependency tree changed
➀ YN0000: β”” Completed in 1s 120ms
➀ YN0000: · Done with warnings in 2s 448ms

but it still gives me Error: Cannot find module 'metro-cache' error.

currently my package.json is

diff --git a/package.json b/package.json
index 8071ba9..0773d41 100644
--- a/package.json
+++ b/package.json
@@ -31,6 +31,7 @@
   },
   "dependencies": {
     "@expo-google-fonts/space-grotesk": "^0.2.2",
+    "@expo/config-plugins": "^6.0.0",
     "@expo/metro-runtime": "~3.1.3",
     "@react-native-async-storage/async-storage": "1.21.0",
     "@react-navigation/bottom-tabs": "^6.3.2",
@@ -48,6 +49,7 @@
     "expo-splash-screen": "~0.26.3",
     "expo-status-bar": "~1.11.1",
     "i18n-js": "3.9.2",
+    "metro-cache": "^0.80.8",
     "mobx": "6.10.2",
     "mobx-react-lite": "4.0.5",
     "mobx-state-tree": "5.3.0",

am I missing anything? thank you ❀️

Ignite version

9.6.3

Additional info

 npx ignite-cli doctor
System
  platform           darwin
  arch               x64
  cpu                8 cores      Apple M2
  directory          PizzaApp     /Users/naoyamakino/git/PizzaApp

/Users/naoyamakino/.npm/_npx/e31027f3785124a8/node_modules/gluegun/build/index.js:15
    throw up;
    ^
Usage Error: The 'yarn global' commands have been removed in 2.x - consider using 'yarn dlx' or a third-party plugin instead

$ yarn run [--inspect] [--inspect-brk] [-T,--top-level] [-B,--binaries-only] [--require #0] <scriptName> ...

(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js v20.11.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions