Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to resolve path to module 'react-native-screens' (ESLint) #62

Closed
gsklee opened this issue Jan 25, 2019 · 9 comments
Closed

Unable to resolve path to module 'react-native-screens' (ESLint) #62

gsklee opened this issue Jan 25, 2019 · 9 comments

Comments

@gsklee
Copy link

gsklee commented Jan 25, 2019

Got this lint error in my VS Code:

Unable to resolve path to module 'react-native-screens'.eslint(import/no-unresolved)
module "react-native-screens"
@codybrouwers
Copy link

I get this error as well, looking in the react-native-screens folder in my node_modules, if I add an node_modules/react-native-screens/index.js file with the following, the ESLint error goes away:

import screens from './src/screens';

export default screens;

@aufamiri
Copy link

happen to me as well, for now I disabled that error by using // eslint-disable-next-line import/no-unresolved

@AChevallier
Copy link

Same problem for me :(
Annoying !

@skleeschulte
Copy link

I fixed this issue by adding the extension .native.js to the eslint-import-resolver-node config in my .eslintrc file:

{
  "parser": "babel-eslint",
  "extends": "airbnb",
  "settings": {
    "import/resolver": {
      "node": {
        "extensions": [".js", ".jsx", ".json", ".native.js"]
      }
    }
  }
}

Explanation: The idea comes from benmosher's comment at eslint-plugin-import. In my case, [".js", ".jsx", ".json"] is the default configuration for the node resolver extensions; this can be found out e.g. by running eslint --print-config index.js. (The eslint-import-resolver-node extensions for the default airbnb config are defined in eslint-config-airbnb/rules/react.js as ['.js', '.jsx', '.json']; eslint-config-airbnb adds rules for React by default: eslint-config-airbnb/index.js.) react-native-screens sets src/screens as main entry point in the package.json file. In the src-folder screens.native.js is the correct entry point for react-native, so adding .native.js to the list of resolver extensions fixes the problem.

@troydaniels
Copy link

Thanks @skleeschulte!
Can confirm that this works for us as well.

@gsklee gsklee closed this as completed Nov 3, 2019
@Jahanzai6
Copy link

I resolve that error by simply
npm install react-native-screens

@tapz
Copy link

tapz commented Feb 12, 2020

After adding the settings to .eslintrc the error changed to this:

enableScreens not found in 'react-native-screens' eslint(import/named)

@Frends23
Copy link

also resolve with
yarn add react-native-screens

@olliefinn
Copy link

I tried all of the options outlined here (and elsewhere) and had no luck. What has seemed to resolve the issue was to add the following to the .flowconfig file

module.file_ext=.native.js

RavenousPett pushed a commit to RavenousPett/the-complete-react-native-and-redux that referenced this issue Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants