使用 expo 通过 NPM 安装包失败
Using expo to install a package with NPM fails
我正在尝试使用 expo 下载 @react-native-community/slider
。这样做失败了
博览会版本:4.12.10
NPM 版本:最新(8.1.2)
我了解到您应该在 https://github.com/callstack/react-native-slider/issues/333
上添加 --legacy-peer-deps
但是,您不能使用 expo 执行此操作。
powershell 输出日志
PS C:\Users154\Downloads\Projects\demo> npm install -g npm@latest
C:\Users154\AppData\Roaming\npm\npm -> C:\Users154\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
C:\Users154\AppData\Roaming\npm\npx -> C:\Users154\AppData\Roaming\npm\node_modules\npm\bin\npx-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:\Users154\Downloads\Projects\demo> npm -v
8.1.2
PS C:\Users154\Downloads\Projects\demo> 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:\Users154\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users154\AppData\Local\npm-cache\_logs21-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:\Users154\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\spawn-async\src\spawnAsync.ts:65:13)
at Object.onceWrapper (node:events:510:26)
at ChildProcess.emit (node:events:390:28)
at ChildProcess.cp.emit (C:\Users154\AppData\Roaming\npm\node_modules\expo-cli\node_modules\cross-spawn\lib\enoent.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:\Users154\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\spawn-async\src\spawnAsync.ts:26:19)
at NpmPackageManager._runAsync (C:\Users154\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\package-manager\src\NodePackageManagers.ts:166:31)
at NpmPackageManager.addAsync (C:\Users154\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\package-manager\src\NodePackageManagers.ts:105:18)
at actionAsync (C:\Users154\AppData\Roaming\npm\node_modules\expo-cli\src\commands\installAsync.ts:122:3)
非常感谢帮助
先安装 NPM 包,然后使用 expo
命令:
npm i --save @react-native-community/slider --legacy-peer-deps
expo install @react-native-community/slider
看起来这对我有用。
我正在尝试使用 expo 下载 @react-native-community/slider
。这样做失败了
博览会版本:4.12.10 NPM 版本:最新(8.1.2)
我了解到您应该在 https://github.com/callstack/react-native-slider/issues/333
上添加 --legacy-peer-deps但是,您不能使用 expo 执行此操作。
powershell 输出日志
PS C:\Users154\Downloads\Projects\demo> npm install -g npm@latest
C:\Users154\AppData\Roaming\npm\npm -> C:\Users154\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
C:\Users154\AppData\Roaming\npm\npx -> C:\Users154\AppData\Roaming\npm\node_modules\npm\bin\npx-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:\Users154\Downloads\Projects\demo> npm -v
8.1.2
PS C:\Users154\Downloads\Projects\demo> 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:\Users154\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users154\AppData\Local\npm-cache\_logs21-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:\Users154\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\spawn-async\src\spawnAsync.ts:65:13)
at Object.onceWrapper (node:events:510:26)
at ChildProcess.emit (node:events:390:28)
at ChildProcess.cp.emit (C:\Users154\AppData\Roaming\npm\node_modules\expo-cli\node_modules\cross-spawn\lib\enoent.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:\Users154\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\spawn-async\src\spawnAsync.ts:26:19)
at NpmPackageManager._runAsync (C:\Users154\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\package-manager\src\NodePackageManagers.ts:166:31)
at NpmPackageManager.addAsync (C:\Users154\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\package-manager\src\NodePackageManagers.ts:105:18)
at actionAsync (C:\Users154\AppData\Roaming\npm\node_modules\expo-cli\src\commands\installAsync.ts:122:3)
非常感谢帮助
先安装 NPM 包,然后使用 expo
命令:
npm i --save @react-native-community/slider --legacy-peer-deps
expo install @react-native-community/slider
看起来这对我有用。