命令
npx react-native init gonative
我在根终端(parrot linux)运行这个命令,遇到了错误。它说找不到模块'metro/src/shared/output/bundle'
节点版本:v17.3.0 npm版本:8.3.0npx版本:8.3.0
输出功率
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'
]
}
1条答案
按热度按时间syqv5f0l1#
1.删除全局react-native安装程序
npm uninstall -g react-native-cli @react-native-community/cli
1.安装Metro捆绑器
npm install --save-dev metro metro-core
1.关闭所有终端/shell,然后再次运行命令