运行 react-native run-ios 时出错。错误:找不到模块“metro-config”
我正在使用 react-native run-is 命令通过终端运行 React-native 项目。我想在模拟器中运行它。首先我运行 npm install,然后运行 react-native run-ios。它显示错误
Error: Cannot find module 'metro-config' Require stack: - /Users/tribond/Projects/JustHelper/justhelper2/node_modules/react-native/local-cli/util/Config.js - /Users/tribond/Projects/JustHelper/justhelper2/node_modules/react-native/local-cli/core/index.js - /Users/tribond/Projects/JustHelper/justhelper2/node_modules/react-native/local-cli/cliEntry.js - /Users/tribond/Projects/JustHelper/justhelper2/node_modules/react-native/local-cli/cli.js - /Users/tribond/Projects/JustHelper/justhelper2/node_modules/react-native/cli.js - /usr/local/lib/node_modules/react-native-cli/index.js
您似乎没有安装
Metro-config
模块。请安装此模块。
npm i metro-config --save-dev
Latest React Native
根据最新的
react-native
文档,您必须更新 metro config 的开发依赖项。
我已使用
更新助手
将
react-native 迁移到 72.4
,请严格遵循指南和文件更改日志,以避免任何遗漏
"devDependencies": {
...,
"@react-native/metro-config": "^0.72.11",
}
Older version of react-native
检查您的
metro-config
开发依赖项
npm i metro-config --save-dev