Composition-api: fix: Using nuxt generate in Netlify builds causes an error

Created on 24 Jul 2021  ·  2Comments  ·  Source: nuxt-community/composition-api

🐛 The bug
When deploying out a nuxt site on Netlify using nuxt generate causes an error.

🛠️ To reproduce
Steps to reproduce the behavior:

  1. Deploy nuxt site using nuxt generate on netlify that uses this plugin.
  2. View failed build

Nuxt generate works fine locally but fails on Netlify builds, could be more a Netlify issue? But wanted to try here first.

yarn generate yarn run v1.22.10 $ nuxt generate [fatal] Package subpath './dist/vue-composition-api.esm.js' is not defined by "exports" in /opt/build/repo/node_modules/@vue/composition-api/package.json at applyExports (internal/modules/cjs/loader.js:491:9) at resolveExports (internal/modules/cjs/loader.js:507:23) at Function.Module._findPath (internal/modules/cjs/loader.js:635:31) at Function.Module._resolveFilename (internal/modules/cjs/loader.js:953:27) at Function.resolve (internal/modules/cjs/helpers.js:78:19) at Function.m [as resolve] (node_modules/jiti/dist/jiti.js:1:52919) at Resolver.resolveModule (node_modules/@nuxt/core/dist/core.js:263:28) at ModuleContainer.compositionApiModule2 (node_modules/@nuxtjs/composition-api/dist/module/index.js:147:22) at ModuleContainer.addModule (node_modules/@nuxt/core/dist/core.js:239:34) at node_modules/@nuxt/utils/dist/utils.js:639:43

🌈 Expected behaviour
Netlify builds out correctly using plugin.

Most helpful comment

The version of Node used by default on Netlify (v12.18.0) does not support subpath exports with patterns (used in @vue/composition-api).

To work around this, you can set the Netlify NODE_VERSION environment variable to 12 or 14, which will enable the latest version of each of those LTS releases.

cc: @ascorbic

That sorted it, thanks!

All 2 comments

The version of Node used by default on Netlify (v12.18.0) does not support subpath exports with patterns (used in @vue/composition-api).

To work around this, you can set the Netlify NODE_VERSION environment variable to 12 or 14, which will enable the latest version of each of those LTS releases.

cc: @ascorbic

The version of Node used by default on Netlify (v12.18.0) does not support subpath exports with patterns (used in @vue/composition-api).

To work around this, you can set the Netlify NODE_VERSION environment variable to 12 or 14, which will enable the latest version of each of those LTS releases.

cc: @ascorbic

That sorted it, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lennartzellmer picture lennartzellmer  ·  3Comments

samnap11 picture samnap11  ·  6Comments

posva picture posva  ·  3Comments

MartinMalinda picture MartinMalinda  ·  7Comments

MartinMalinda picture MartinMalinda  ·  4Comments