简体   繁体   English

错误:无法解析模块react-redux / native

[英]Error: Unable to resolve module react-redux/native

I am trying my first react-native application with Redux and on running the application on device getting below error message, 我正在尝试使用Redux的第一个react-native应用程序,并在设备上运行应用程序时收到以下错误消息,

"UnableToResolveError: Unable to resolve module react-redux/native from C:\\project\\Testing\\index.android.js: Module does not exist in the module map or in these directories: C:\\project\\Testing\\node_modules\\react-redux" “UnableToResolveError:无法从C:\\ project \\ Testing \\ index.android.js解析模块react-redux / native:模块映射或这些目录中不存在模块:C:\\ project \\ Testing \\ node_modules \\ react-终极版”

package.json: 的package.json:

{ {
"name": "Testing", “名称”:“测试”,
"version": "0.0.1", “版本”:“0.0.1”,
"private": true, “私人”:是的,
"scripts": { “脚本”:{
"start": "node node_modules/react-native/local-cli/cli.js start", “start”:“node node_modules / react-native / local-cli / cli.js start”,
"test": "jest" “测试”:“开玩笑”
}, },
"dependencies": { “依赖”:{
"react": "15.4.1", “反应”:“15.4.1”,
"react-native": "0.40.0", “本土反应”:“0.40.0”,
"react-redux": "^5.0.2", “react-redux”:“^ 5.0.2”,
"redux": "^3.6.0", “redux”:“^ 3.6.0”,
"redux-thunk": "^2.2.0" “redux-thunk”:“^ 2.2.0”
}, },
"devDependencies": { “devDependencies”:{
"babel-jest": "18.0.0", “babel-jest”:“18.0.0”,
"babel-preset-react-native": "1.9.1", “babel-preset-react-native”:“1.9.1”,
"jest": "18.1.0", “开玩笑”:“18.1.0”,
"react-test-renderer": "15.4.1" “react-test-renderer”:“15.4.1”
}, },
"jest": { “开玩笑”:{
"preset": "react-native" “预设”:“反应原生”
} }
} }

index.android.js: index.android.js:

import React, { AppRegistry } from 'react-native';
import { Provider } from 'react-redux/native';
import App from './src/containers/App';
import configStore from './src/stores/configStore';
const store = configStore();
var TestingApp = React.createClass({
  render () {
    return (
      ...
    );
  }
});
AppRegistry.registerComponent('TestingApp', () => TestingApp);

Kindly assist to solve the issue. 请协助解决问题。

From index.js of react-redux , you could get that Provider is exported by react-redux directly. react-redux的index.js ,您可以直接通过react-redux导出Provider

So you should use import { Provider } from 'react-redux' instead of import { Provider } from 'react-redux/native' . 所以你应该使用import { Provider } from 'react-redux'import { Provider } from 'react-redux/native'而不是import { Provider } from 'react-redux/native'import { Provider } from 'react-redux/native'

You can also check the example from here . 您也可以从这里查看示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到模块:错误:无法解析模块“react-redux” - Module not found: Error: Cannot resolve module 'react-redux' 无法解决 React Native Redux 工具包中的模块错误 - Unable to resolve module Error in React Native Redux Toolkit 无法解析模块-在React Native中导入Redux - Unable to resolve module - importing Redux in React Native 错误:无法从C:\\ Users \\ wanuuu27 \\ AwesomeProject \\ App.js中解析模块`react-redux`:模块`react-redux`不存在 - Error: Unable to resolve module `react-redux` from `C:\Users\wanuuu27\AwesomeProject\App.js`: Module `react-redux` does not exist [eslint]'react-redux'应该在项目的依赖项中列出,无法解析模块'react-redux'的路径 - [eslint]'react-redux' should be listed in the project's dependency+unable to resolve path to module 'react-redux' React Native - react-redux PropTypes 错误 - React Native - react-redux PropTypes error 将大型Redux代码库添加到React Native /无法解决模块错误 - Adding large Redux code base to React Native / Unable to resolve module error 错误:无法解析模块 `buffer` React Native - Error: Unable to resolve module `buffer` React Native React Native 与 TypeScript 错误无法解析模块 - React Native with TypeScript Error unable to resolve module 无法解析模块“ react-redux / lib / components / connect” - Cannot resolve module 'react-redux/lib/components/connect'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM