Closed
Description
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
:
var App = 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`
const forgive = (error) => {
if (error.type !== 'UnableToResolveError') {
throw error;
}
console.warn(
'Unable to resolve module %s from %s',
toModuleName,
fromModule.path
);
return null;
};
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
.