diff --git a/src/utils/defaults.js b/src/utils/defaults.js index 08e16f2..c746a7f 100644 --- a/src/utils/defaults.js +++ b/src/utils/defaults.js @@ -7,11 +7,15 @@ export function load ( id ) { } function addJsExtensionIfNecessary ( file ) { - const name = basename( file ); - const files = readdirSync( dirname( file ) ); - - if ( ~files.indexOf( name ) && isFile( file ) ) return file; - if ( ~files.indexOf( `${name}.js` ) && isFile( `${file}.js` ) ) return `${file}.js`; + try { + const name = basename( file ); + const files = readdirSync( dirname( file ) ); + + if ( ~files.indexOf( name ) && isFile( file ) ) return file; + if ( ~files.indexOf( `${name}.js` ) && isFile( `${file}.js` ) ) return `${file}.js`; + } catch ( err ) { + // noop + } return null; }