Skip to content

Incorrect resolve js file as directory #2825

Description

@chentsulin

In my project, I have directories structure like below:

/project-name
/native
/ios
index.ios.js
/src
/containers
App.js

And I require App.js in my index.ios.js:

varApp=require('../src/containers/App');

I get a warning:

Unable to resolve module ../src/containers/App.js from /Users/username/Projects/project-name/native/index.ios.js

I thought we should not hide detail information about a happened error here:

// node_modules/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/ResolutionRequest.js`constforgive=(error)=>{if(error.type!=='UnableToResolveError'){throwerror;}console.warn('Unable to resolve module %s from %s',toModuleName,fromModule.path);returnnull;};

Anyway, I add a console.error(error) for this, and see following error message print out:

{ [UnableToResolveError: Invalid directory /Users/username/Projects/project-name/src/containers/App]
message: 'Invalid directory /Users/username/Projects/project-name/src/containers/App',
name: 'UnableToResolveError',
type: 'UnableToResolveError' }

Why require('../src/containers/App') will try to resolve a directory there? I expected it should resolve ../src/containers/App.js.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions