diff --git a/packages/core/src/module.js b/packages/core/src/module.js index 466db6af5c..6a43e980cb 100644 --- a/packages/core/src/module.js +++ b/packages/core/src/module.js @@ -157,6 +157,8 @@ export default class ModuleContainer { if (!handler) { try { handler = this.nuxt.resolver.requireModule(src, { paths }) + // pnp support + try { (global.__NUXT_PATHS__ || []).push(this.nuxt.resolver.resolvePath(src, { paths })) } catch (_err) {} } catch (error) { if (error.code !== 'MODULE_NOT_FOUND') { throw error diff --git a/packages/webpack/src/config/base.js b/packages/webpack/src/config/base.js index 2d1175c47a..c119db7aa1 100644 --- a/packages/webpack/src/config/base.js +++ b/packages/webpack/src/config/base.js @@ -228,6 +228,7 @@ export default class WebpackBaseConfig { const resolvePath = [ this.buildContext.options.rootDir, __dirname, + ...(global.__NUXT_PATHS__ || []), resolveModule('@nuxt/vue-app'), resolveModule('@nuxt/babel-preset-app') ]