#react-native #npm #expo
Вопрос:
Я пытаюсь загрузить @react-native-community/slider
с помощью expo. Сделать это не удается
Версия Expo: 4.12.10 Версия NPM: последняя(8.1.2)
Я читал, что вы должны добавить —legacy-peer-deps на https://github.com/callstack/react-native-slider/issues/333
Однако вы не можете сделать это с помощью expo.
Журналы выходных данных powershell
PS C:Users15154DownloadsProjectsdemo> npm install -g npm@latest
C:Users15154AppDataRoamingnpmnpm -> C:Users15154AppDataRoamingnpmnode_modulesnpmbinnpm-cli.js
C:Users15154AppDataRoamingnpmnpx -> C:Users15154AppDataRoamingnpmnode_modulesnpmbinnpx-cli.js
npm@8.1.2
added 70 packages from 18 contributors, removed 289 packages and updated 148 packages in 20.49s
╭───────────────────────────────────────────────────────────────╮
│ │
│ New major version of npm available! 6.14.15 -> 8.1.2 │
│ Changelog: https://github.com/npm/cli/releases/tag/v8.1.2 │
│ Run npm install -g npm to update! │
│ │
╰───────────────────────────────────────────────────────────────╯
PS C:Users15154DownloadsProjectsdemo> npm -v
8.1.2
PS C:Users15154DownloadsProjectsdemo> expo install @react-native-community/slider
Installing 1 SDK 43.0.0 compatible native module using npm.
> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR! react@"17.0.1" from the root project
npm ERR! peer react@"*" from @react-native-community/slider@4.1.7
npm ERR! node_modules/@react-native-community/slider
npm ERR! 1 more (react-native)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.2" from react-native-windows@0.66.2
npm ERR! node_modules/react-native-windows
npm ERR! peer react-native-windows@"*" from @react-native-community/slider@4.1.7
npm ERR! node_modules/@react-native-community/slider
npm ERR! @react-native-community/slider@"4.1.7" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:Users15154AppDataLocalnpm-cacheeresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:Users15154AppDataLocalnpm-cache_logs2021-10-31T23_22_12_319Z-debug.log
npm exited with non-zero code: 1
Error: npm exited with non-zero code: 1
at ChildProcess.completionListener (C:Users15154AppDataRoamingnpmnode_modulesexpo-clinode_modules@expospawn-asyncsrcspawnAsync.ts:65:13)
at Object.onceWrapper (node:events:510:26)
at ChildProcess.emit (node:events:390:28)
at ChildProcess.cp.emit (C:Users15154AppDataRoamingnpmnode_modulesexpo-clinode_modulescross-spawnlibenoent.js:34:29)
at maybeClose (node:internal/child_process:1064:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
...
at Object.spawnAsync [as default] (C:Users15154AppDataRoamingnpmnode_modulesexpo-clinode_modules@expospawn-asyncsrcspawnAsync.ts:26:19)
at NpmPackageManager._runAsync (C:Users15154AppDataRoamingnpmnode_modulesexpo-clinode_modules@expopackage-managersrcNodePackageManagers.ts:166:31)
at NpmPackageManager.addAsync (C:Users15154AppDataRoamingnpmnode_modulesexpo-clinode_modules@expopackage-managersrcNodePackageManagers.ts:105:18)
at actionAsync (C:Users15154AppDataRoamingnpmnode_modulesexpo-clisrccommandsinstallAsync.ts:122:3)
Помощь была бы значительно оценена
Ответ №1:
Сначала установите пакет NPM, а затем используйте expo
команду:
npm i --save @react-native-community/slider --legacy-peer-deps
expo install @react-native-community/slider
Похоже, это сработало для меня.