首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用expo安装NPM包失败

使用expo安装NPM包失败
EN

Stack Overflow用户
提问于 2021-10-31 23:27:58
回答 1查看 304关注 0票数 0

我正在尝试使用expo下载@react-native-community/slider。这样做会失败

Expo版本: 4.12.10 NPM版本: lastest(8.1.2)

我读到过你应该在https://github.com/callstack/react-native-slider/issues/333上添加--遗留同级-dep

但是,您不能在expo中做到这一点。

powershell输出的日志

代码语言:javascript
复制
PS C:\Users\15154\Downloads\Projects\demo> npm install -g npm@latest
C:\Users\15154\AppData\Roaming\npm\npm -> C:\Users\15154\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
C:\Users\15154\AppData\Roaming\npm\npx -> C:\Users\15154\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:\Users\15154\Downloads\Projects\demo> npm -v
8.1.2
PS C:\Users\15154\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:\Users\15154\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:\Users\15154\AppData\Local\npm-cache\_logs\2021-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:\Users\15154\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:\Users\15154\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:\Users\15154\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\spawn-async\src\spawnAsync.ts:26:19)
    at NpmPackageManager._runAsync (C:\Users\15154\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\package-manager\src\NodePackageManagers.ts:166:31)
    at NpmPackageManager.addAsync (C:\Users\15154\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\package-manager\src\NodePackageManagers.ts:105:18)
    at actionAsync (C:\Users\15154\AppData\Roaming\npm\node_modules\expo-cli\src\commands\installAsync.ts:122:3)

帮助将会得到极大的评价

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-11 13:57:18

先安装NPM包,然后使用expo命令:

代码语言:javascript
复制
npm i --save @react-native-community/slider --legacy-peer-deps
expo install @react-native-community/slider

看起来这对我很管用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69791350

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档