npm无法找到某些react-native模块的依赖项 [英] npm can't find dependencies for some react-native modules

查看:90
本文介绍了npm无法找到某些react-native模块的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用create-react-native-app创建一个React Native应用

I'm creating a react native app using create-react-native-app

npm create-react-native-app 

我将react-native版本更新为0.44.0,这需要将react版本更新为16.0.0-alpha.6这是我的package.json

I updated react-native version to 0.44.0, which requires to update react version to 16.0.0-alpha.6 This is my package.json

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-native-scripts": "0.0.29",
    "jest-expo": "^0.4.0",
    "react-test-renderer": "~15.5.4"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "node node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/ex-navigation": "^2.11.1",
    "babel-preset-react-native-stage-0": "^1.0.1",
    "expo": "^16.0.0",
    "react": "~16.0.0-alpha.6",
    "react-native": "0.44.0"
  }
}

运行npm install会出现以下错误

Running npm install gives me following errors

C:\dev\repo\test>npm install
npm WARN lottie-react-native@1.1.1 requires a peer of react@>=15.3.1 but none was installed.
npm WARN react-native-maps@0.12.2 requires a peer of react@>=15.4.0 but none was installed.
npm WARN react-native-svg@4.4.1 requires a peer of react@>=15.4.0 but none was installed.
npm WARN react-static-container@1.0.1 requires a peer of react@^0.13.0 || ^0.14.0 || ^15.0.0 but none was installed.

看起来lotty-react-native,react-native-map,react-native-svg和react-static-container无法识别react版本16.0.0-alpha.6.我不确定是否必须满足主要版本(15),或者这些库未使用Alpha版本16或其他功能.有谁知道如何解决这一问题?谢谢.

It looks like react version 16.0.0-alpha.6 is not recognized by lottie-react-native, react-native-maps, react-native-svg, and react-static-container. I'm not sure if major version (15) must be met, or the alpha version 16 is not picked up by those libraries, or something else. Does anyone know how to fix this? Thanks.

推荐答案

我只是通过删除node_modules中的react-native文件夹并通过运行此命令重新安装react-native来解决同一问题

I just solve the same issue by removing the react-native folder in node_modules and reinstall the react-native by run this command

  1. 删除node_modules中的react-native文件夹
  2. 通过运行 npm install react-native
  3. 重新安装react-native
  1. Delete the react-native folder in node_modules
  2. Reinstall react-native by run npm install react-native

我认为比删除整个node_modules更简单,因为仅是react-native软件包及其package.json丢失了.

I think is more simply than deleting the entire node_modules as only the react-native packages and its package.json is missing.

这篇关于npm无法找到某些react-native模块的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆