Почему НАЯ установка не реагируют с package.json?

Обновить

March 2019

Просмотры

1.2k раз

1

Если удалить мои node_modules и сделать чистую НПМ установить в моем ReactNative проекта, я получаю предупреждение «[email protected] требует пэр [email protected]~15.3.1, но не был установлен ни один.» Тем не менее, я срабатывают в списке зависимостей в файле package.json:

{
  "name": "MyApp",
  "version": "1.1.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },  
  "dependencies": {
    "lodash": "^4.17.2",
    "moment": "^2.16.0",
    "react": "^15.3.1",
    "react-native": "^0.37.0",
    "react-native-drawer": "^2.2.6",
    "react-native-htmlview": "^0.5.0",
    "react-native-keyboard-spacer": "^0.3.0",
    "react-native-material-design": "^0.3.7",
    "react-native-modal-picker": "0.0.16",
    "react-native-modalbox": "^1.3.4",
    "react-native-vector-icons": "^3.0.0",
    "react-native-viewpager": "^0.2.13",
    "rebound": "0.0.13"
  }
}

1 ответы

2

Your react dependency version is ^15.3.1. The caret character ^ in semver allows any version within the minor range for version major.minor.patch. NPM currently resolves this to 15.4.2.

The react peer dependency in React Native, on the other hand, is ~15.3.1. The tilde character ~ only allows variation within the patch version, so it's not compatible with 15.4.2.

Define your react dependency as ~15.3.1, and you'll get the right version.