"unable to resolve module 'react/lib/React' from '.../react-konva/src/react-konva.js'" 尝试构建时出错
"unable to resolve module 'react/lib/React' from '.../react-konva/src/react-konva.js'" error when trying to build
我对 React 有点陌生,这是我的第一个项目,但花了很多时间学习和编写 react-native 代码。
我想我已经确定了为什么会出现错误,但我不知道如何修复它。
我想做的是安装 运行 react-konva,这是一个 canvas 元素库,它使用 Konva.js 在我的应用程序中有效地显示 Canvas 元素.在 运行ning yarn add konva react-konva --save
(已经做出反应)之后,我 运行 陷入依赖问题,react-konva 需要 react@15.6.1
,但我项目的其他部分需要 react@16.0.0-alpha.12
。从而引发问题。关于它发生的原因(如果我不对)或如何解决这个问题的任何见解都将是惊人的。
This is the Red error screen in the emulator when i have as much as import { Stage } from 'react-konva';
in my code.
an npm list --depth=0
of my project to show the dependencies.
Package.json
:
{
"name": "amazingProject",
"version": "0.0.1",
"private": true,
"main": "node_modules\expo\AppEntry.js",
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"konva": "^1.6.7",
"prop-types": "^15.5.10",
"react-addons-shallow-compare": "^15.6.0",
"react-konva": "^1.1.4",
"react-native": "0.45.1",
"react-native-cli": "^2.0.1",
"react-native-lightbox": "^0.6.0",
"react-native-modal-dropdown": "^0.4.4",
"react-native-side-menu": "^0.20.3",
"react-native-slider": "0.10.0",
"react-native-vector-icons": "^4.2.0",
"react-navigation": "1.0.0-beta.11",
"style-equal": "^1.0.0",
"watchman": "^0.1.8",
"yarn": "^0.27.5"
},
"devDependencies": {
"babel-jest": "20.0.3",
"babel-preset-react-native": "2.0.0",
"jest": "20.0.4",
"react": "16.0.0-alpha.12",
"react-dom": "16.0.0-alpha.12",
"react-test-renderer": "16.0.0-alpha.12"
},
"peerDependencies": {
"react": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
}
}
react-konva
尚不支持新的 React v16。
你可以尝试使用 v15.6.1
的反应。或等待更新 react-konva
:
我对 React 有点陌生,这是我的第一个项目,但花了很多时间学习和编写 react-native 代码。
我想我已经确定了为什么会出现错误,但我不知道如何修复它。
我想做的是安装 运行 react-konva,这是一个 canvas 元素库,它使用 Konva.js 在我的应用程序中有效地显示 Canvas 元素.在 运行ning yarn add konva react-konva --save
(已经做出反应)之后,我 运行 陷入依赖问题,react-konva 需要 react@15.6.1
,但我项目的其他部分需要 react@16.0.0-alpha.12
。从而引发问题。关于它发生的原因(如果我不对)或如何解决这个问题的任何见解都将是惊人的。
This is the Red error screen in the emulator when i have as much as import { Stage } from 'react-konva';
in my code.
an npm list --depth=0
of my project to show the dependencies.
Package.json
:
{
"name": "amazingProject",
"version": "0.0.1",
"private": true,
"main": "node_modules\expo\AppEntry.js",
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"konva": "^1.6.7",
"prop-types": "^15.5.10",
"react-addons-shallow-compare": "^15.6.0",
"react-konva": "^1.1.4",
"react-native": "0.45.1",
"react-native-cli": "^2.0.1",
"react-native-lightbox": "^0.6.0",
"react-native-modal-dropdown": "^0.4.4",
"react-native-side-menu": "^0.20.3",
"react-native-slider": "0.10.0",
"react-native-vector-icons": "^4.2.0",
"react-navigation": "1.0.0-beta.11",
"style-equal": "^1.0.0",
"watchman": "^0.1.8",
"yarn": "^0.27.5"
},
"devDependencies": {
"babel-jest": "20.0.3",
"babel-preset-react-native": "2.0.0",
"jest": "20.0.4",
"react": "16.0.0-alpha.12",
"react-dom": "16.0.0-alpha.12",
"react-test-renderer": "16.0.0-alpha.12"
},
"peerDependencies": {
"react": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
}
}
react-konva
尚不支持新的 React v16。
你可以尝试使用 v15.6.1
的反应。或等待更新 react-konva
: