最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - "Unknown named module" error in react native - Stack Overflow

programmeradmin0浏览0评论

I'm creating an app using react native but some imports raise the error from the title: "Unknown named module". This happens with two packages, react-native-material-design and react-native-db-models, so I suspect the problem isn't on the modules but in my setup.

I tried linking the packages with react-native link and repackaging the app using react-native run-android, but none of these solved this issue. I've looked up examples of imports on github, and even copying working code raises the same error.

I tried installing the modules using either yarn and npm. I tried with relative paths like ../../react-native-db-models. Didn't work!

This is how I import the modules:

import RNDBModel from 'react-native-db-models';

import { List, Button, Toolbar, } from 'react-native-material-design';

These are my project dependencies:

"dependencies": {
  "react": "15.4.1",
  "react-native": "0.39.2",
  "react-native-db-models": "^0.1.3",
  "react-native-material-design": "^0.3.7",
  "react-native-md-textinput": "^2.0.4",
  "react-native-vector-icons": "0.8.5",
  "react-redux": "^5.0.1",
  "redux": "^3.6.0",
  "redux-logger": "^2.7.4"
},

If React/React Native is incompatible with these modules, how do I figure out which version should I use? Maybe the error has nothing to do with imports and has something to do with my project?

I'm creating an app using react native but some imports raise the error from the title: "Unknown named module". This happens with two packages, react-native-material-design and react-native-db-models, so I suspect the problem isn't on the modules but in my setup.

I tried linking the packages with react-native link and repackaging the app using react-native run-android, but none of these solved this issue. I've looked up examples of imports on github, and even copying working code raises the same error.

I tried installing the modules using either yarn and npm. I tried with relative paths like ../../react-native-db-models. Didn't work!

This is how I import the modules:

import RNDBModel from 'react-native-db-models';

import { List, Button, Toolbar, } from 'react-native-material-design';

These are my project dependencies:

"dependencies": {
  "react": "15.4.1",
  "react-native": "0.39.2",
  "react-native-db-models": "^0.1.3",
  "react-native-material-design": "^0.3.7",
  "react-native-md-textinput": "^2.0.4",
  "react-native-vector-icons": "0.8.5",
  "react-redux": "^5.0.1",
  "redux": "^3.6.0",
  "redux-logger": "^2.7.4"
},

If React/React Native is incompatible with these modules, how do I figure out which version should I use? Maybe the error has nothing to do with imports and has something to do with my project?

Share Improve this question asked Dec 19, 2016 at 23:54 Marco LavagninoMarco Lavagnino 1,22916 silver badges36 bronze badges 2
  • For the react-native-material-design package. I am using it on a different project and is working fine. But for the react-native-db-models. I am not sure. It hasn't been updated for a years. Could you give an output of an example with only the react-native-material-design package ? – Saad Touhbi Commented Dec 20, 2016 at 0:25
  • @SaadBen same error: Unknown named module: "react-native-material-design" – Marco Lavagnino Commented Dec 20, 2016 at 1:02
Add a comment  | 

2 Answers 2

Reset to default 16

The package server started by react-native start seems to have a cache of the node modules. Stopping and restarting the server solved the issue.

Always restart your react server after installing modules!

A quick check on the package's repository shows 'List' module is no longer available. Here is a link to why it was removed.

So, you will have to remove 'List' module from your import:

import { Button, Toolbar, } from 'react-native-material-design';
发布评论

评论列表(0)

  1. 暂无评论