react-native-screens icon indicating copy to clipboard operation
react-native-screens copied to clipboard

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

Open gsklee opened this issue 7 years ago • 9 comments

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"

gsklee avatar Jan 25 '19 01:01 gsklee

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;

codybrouwers avatar Feb 11 '19 18:02 codybrouwers

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

aufamiri avatar Feb 18 '19 11:02 aufamiri

Same problem for me :( Annoying !

AChevallier avatar May 21 '19 16:05 AChevallier

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.

skleeschulte avatar May 23 '19 10:05 skleeschulte

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

troydaniels avatar May 31 '19 05:05 troydaniels

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

Jahanzai6 avatar Feb 01 '20 09:02 Jahanzai6

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

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

tapz avatar Feb 12 '20 19:02 tapz

also resolve with yarn add react-native-screens

Frends23 avatar Feb 29 '20 00:02 Frends23

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

olliefinn avatar Mar 23 '20 08:03 olliefinn