Skip to content

Confusing error message when "basedir" is not a directory #154

@gaearon

Description

@gaearon

I mistakingly passed a filename as basedir option.
I found the error message quite confusing:

TypeError: Cannot read property 'isFile' of undefined
    at isFile (/Users/gaearon/p/test113/node_modules/resolve/lib/sync.js:12:20)
    at loadAsFileSync (/Users/gaearon/p/test113/node_modules/resolve/lib/sync.js:36:13)
    at loadNodeModulesSync (/Users/gaearon/p/test113/node_modules/resolve/lib/sync.js:75:21)

This is because there is an early exit for "file not found" errors, but for any other errors we fall through to where stat doesn't exist.

Just filing this for future readers.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions