react-native icon indicating copy to clipboard operation
react-native copied to clipboard

installing error with Metro Bundle MODULE_NOT_FOUND

Open AhmedFatehy opened this issue 4 years ago • 4 comments

Description

I'm trying to setup react-native as documentation instruction, installed the following apps;

  • Git-2.35.1.2-64-bit
  • MSVC 2013 X86 - V12.0.30501
  • MSVC 2013 X64 - V12.0.30501
  • MSVC 2015-2022 X86 - V14.30.30708.0
  • MSVC 2015-2019 X64 - V14.30.30139.0
  • node-v17.5.0-x64 - with necessary additional packages
  • Android Studio 2021.1.1 with all required configuration

I created a folder for projects and tried npx react-native init xxxxxx it gives me the following error

PS C:\Users\ahmed> npx react-native
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'metro/src/shared/output/bundle'
Require stack:
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\bundle\buildBundle.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\bundle\bundle.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\bundle\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli\build\commands\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli\build\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli\build\bin.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\bundle\buildBundle.js:64:22)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\buildBundle.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\bundle.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\commands\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli\\build\\commands\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli\\build\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli\\build\\bin.js'
  ]
}

Node.js v17.5.0

NODE: 17.5.0 NPM: 8.5.0 OS Name: Microsoft Windows 10 Pro OS Version: 10.0.19043 N/A Build 19043 System Type: x64-based PC Processor(s): 1 Processor(s) Installed. [01]: Intel64 Family 6 Model 142 Stepping 10 Genuine Intel ~1792 Mhz Total Physical Memory: 8,067 MB

Version

LATEST

Output of npx react-native info

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'metro/src/shared/output/bundle'
Require stack:
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\bundle\buildBundle.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\bundle\bundle.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\bundle\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli\build\commands\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli\build\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli\build\bin.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\bundle\buildBundle.js:64:22)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\buildBundle.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\bundle.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\commands\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli\\build\\commands\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli\\build\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli\\build\\bin.js'
  ]
}

Node.js v17.5.0
```node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'metro/src/shared/output/bundle'
Require stack:
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\bundle\buildBundle.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\bundle\bundle.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\bundle\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli\build\commands\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli\build\index.js
- C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli\build\bin.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\ahmed\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\@react-native-community\cli-plugin-metro\build\commands\bundle\buildBundle.js:64:22)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\buildBundle.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\bundle.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\commands\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli-plugin-metro\\build\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli\\build\\commands\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli\\build\\index.js',
    'C:\\Users\\ahmed\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\@react-native-community\\cli\\build\\bin.js'
  ]
}

Node.js v17.5.0

### Steps to reproduce

- I removed node and npm with all related files many times and reinstall it again bust with the same error
- change the node version from v16.14.0 to 17.5.0 
- update the npm from 8.3.1 to 8.5.0
- install metro `npm install --save-dev metro metro-core`

### Snack, code example, screenshot, or link to a repository

_No response_

AhmedFatehy avatar Feb 15 '22 21:02 AhmedFatehy

This question may case by node path config.

npm config set prefix "XXX\XXX\node_global"

npm config set cache "XXX\XXX\node_cache"

FansPro avatar Mar 20 '22 15:03 FansPro

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Sep 17 '22 02:09 github-actions[bot]

please I am facing thesame problem too, but I didn't see any solution here

iredox10 avatar Oct 10 '22 23:10 iredox10

Also i am facing this problem. How to fix this ?

dransidu avatar Oct 20 '22 02:10 dransidu

Been facing same.

vinodpatildev avatar Jan 05 '23 14:01 vinodpatildev

Same issue after trying to downgrade to metro 0.73.9 from 0.76.3 with my react native app

ucheNkadiCode avatar May 06 '23 19:05 ucheNkadiCode

i got same issue

asadalibest1 avatar May 30 '23 10:05 asadalibest1

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Mar 21 '24 05:03 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Mar 28 '24 05:03 github-actions[bot]