diff --git a/lib/module.js b/lib/module.js index ad73aeaeb1..b02ed3b39e 100755 --- a/lib/module.js +++ b/lib/module.js @@ -95,9 +95,9 @@ class Module { let module try { if (typeof src === 'string') { - // Using ~ shorthand modules are resolved from project srcDir + // Using ~ shorthand to resolve from project srcDir if (src.indexOf('~') === 0) { - src = path.resolve(this.options.srcDir, src.substr(1)) + src = path.resolve(this.options.srcDir, src.replace(/^~\/?/, '')) } // eslint-disable-next-line no-eval module = eval('require')(src) @@ -107,13 +107,14 @@ class Module { console.error('[Nuxt] Unable to resolve module', src) // eslint-disable-next-line no-console console.error(e) - return + process.exit(0) } // Validate module /* istanbul ignore if */ if (!(module instanceof Function)) { // eslint-disable-next-line no-console console.error('[Nuxt] Module should be a function', module) + process.exit(0) } // Add module to this.modules this.modules.push(module) diff --git a/lib/server.js b/lib/server.js index 53cc60379f..44413301ec 100644 --- a/lib/server.js +++ b/lib/server.js @@ -25,7 +25,7 @@ class Server { let src = m // Using ~ shorthand to resolve from project srcDir if (src.indexOf('~') === 0) { - src = path.resolve(this.nuxt.options.srcDir, src.substr(1)) + src = path.resolve(this.nuxt.options.srcDir, src.replace(/^~\/?/, '')) } // eslint-disable-next-line no-eval m = eval('require')(src)