RoyalBosS
RoyalBosS

Reputation: 450

React Native Error: Cannot find module metro/src/shared/output/bundle

command

npx react-native init gonative 

I ran this command in root terminal (parrot linux) and encountered with error. It says cannot find module 'metro/src/shared/output/bundle'

Node version : v17.3.0 npm version: 8.3.0 npx version : 8.3.0

output

Need to install the following packages:
  react-native
Ok to proceed? (y) y
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'metro/src/shared/output/bundle'
Require stack:
- /root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli-plugin-metro/build/commands/bundle/buildBundle.js
- /root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli-plugin-metro/build/commands/bundle/bundle.js
- /root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli-plugin-metro/build/commands/bundle/index.js
- /root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli-plugin-metro/build/commands/index.js
- /root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli-plugin-metro/build/index.js
- /root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/commands/index.js
- /root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/index.js
- /root/.npm/_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> (/root/.npm/_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:1149: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: [
    '/root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli-plugin-metro/build/commands/bundle/buildBundle.js',
    '/root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli-plugin-metro/build/commands/bundle/bundle.js',
    '/root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli-plugin-metro/build/commands/bundle/index.js',
    '/root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli-plugin-metro/build/commands/index.js',
    '/root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli-plugin-metro/build/index.js',
    '/root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/commands/index.js',
    '/root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/index.js',
    '/root/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/bin.js'
  ]
}

Upvotes: 5

Views: 2246

Answers (1)

KaePee
KaePee

Reputation: 41

  1. Remove global react-native installer npm uninstall -g react-native-cli @react-native-community/cli

  2. Install metro bundler npm install --save-dev metro metro-core

  3. Close all terminal/shell, and then run your command again

Upvotes: 4

Related Questions