我是编码的初学者,这意味着我遵循youtube上的教程。我正在做的项目是一个Uber克隆。当我试图安装:
expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view
它给我错误信息说:
使用npm安装4个SDK 45.0.0兼容的本地模块和1个其他包。
npm安装npm犯错!代码ERESOLVEnpm犯错!erresolve无法解析npm犯错!npm犯错!同时解决:react-native-elements@3.4.2npm犯错!发现:react-native-safe-area-context@4.2.4npm犯错!node_modules/react-native-safe-area-contextnpm犯错!react-native-safe-area-context@" 4.2.4"从根项目npm犯错!npm犯错!无法解决依赖项:npm犯错!同行react-native-safe-area-context@" ^ 3.1.9"从react-native-elements@3.4.2npm犯错!node_modules/react-native-elementsnpm犯错!react-native-elements@" ^ 3.4.2"从根项目
npm ERR!npm犯错!冲突的对等依赖:react-native-safe-area-context@3.4.1npm犯错!node_modules/react-native-safe-area-contextnpm犯错!同行react-native-safe-area-context@" ^ 3.1.9"从react-native-elements@3.4.2npm犯错!node_modules/react-native-elementsnpm犯错!react-native-elements@" ^ 3.4.2"从根项目
npm ERR!npm犯错!修复上游依赖冲突,或者重试npm犯错!这个命令带有——force或——legacy-peer-depsnpm犯错!接受不正确(并且可能损坏)的依赖项决议。npm犯错!npm犯错!完整的报告请参见C:Usersps3plAppDataLocalnpm-cache erresolve -report.txt。
npm犯错!这次运行的完整日志可以在下面找到:npm犯错!C:Usersps3plAppDataLocal npm-cache_logs 2022 - 06 - 05 - t13_17_47_604z -调试- 0. -日志
npm退出非零代码错误:npm以非零代码退出:1(C:Usersps3plAppDataRoamingnpmnode_modulesexpo-clinode_modules@expospawn-asyncsrcspawnAsync.ts:65:13)在对象。onceWrapper(节点:事件:514:26)在ChildProcess。发出(节点:事件:394:28)在ChildProcess.cp.emit (C:Usersps3plAppDataRoamingnpmnode_modulesexp -clinode_modulescross-spawnlib enenet .js:34:29)
at mayclose (node:internal/child_process:1067:16)在Process.ChildProcess._handle。onexit(节点:内部/child_process 301:5):…在对象。(C:Usersps3plAppDataRoamingnpmnode_modulesexpo-clinode_modules@expospawn-asyncsrcspawnAsync.ts:26:19)在NpmPackageManager。_runAsync (C:Usersps3plAppDataRoamingnpmnode_modulesexpo-clinode_modules@expopackage-managersrcNodePackageManagers.ts: 165:31)
(C:Usersps3plAppDataRoamingnpmnode_modulesexpo-clinode_modules@expopackage-managersrcNodeP at actionAsync (C:Usersps3plAppDataRoamingnpmnode_modulesexpo-clisrccommandsinstallAsync.ts:125:3)
{
"name": "uber-clone",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"@react-navigation/native": "^6.0.10",
"@reduxjs/toolkit": "^1.8.2",
"expo": "~45.0.0",
"expo-status-bar": "~1.3.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.68.2",
"react-native-elements": "^3.4.2",
"react-native-safe-area-context": "4.2.4",
"react-native-vector-icons": "^9.1.0",
"react-native-web": "0.17.7",
"react-redux": "^8.0.2",
"tailwind-react-native-classnames": "^1.5.1",
"react-native-gesture-handler": "~2.2.1",
"react-native-reanimated": "~2.8.0",
"react-native-screens": "~3.11.1"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},
"private": true
}
谢谢
以下步骤对我有效:
在代码编辑器中打开代码,通过运行npm uninstall react-native-safe-area-context
删除依赖项react-native-safe-area-context运行npm update
先删除node_modules
文件夹,然后运行npm install
重新安装。然后在代码编辑器中打开代码,通过运行npm uninstall react-native-safe-area-context
react-native-safe-area-context
。可以全局安装
npm install -g npm@latest
这是我的工作!