Search code examples
nuxt.jsrequirees6-modulesvue-composition-apistoryblok

require() of ES Module when using @nuxtjs/composition-api


I have the following error in my nuxt-2 + storyblok project, when I switched from @vue/composition-api to @nuxtjs/composition-api:

require() of ES Module /Users/my-user/Sites/my-project/node_modules/@nuxtjs/composition-api/dist/runtime/index.mjs not supported. Instead change the require of /Users/my-user/Sites/my-project/node_modules/@nuxtjs/composition-api/dist/runtime/index.mjs to a dynamic import() which is available in all CommonJS modules.

my console log also throws: Uncaught InternalError: too much recursion

I already use "type":"module" in my package.json. -> It makes no difference whether I remove it or not.

Some version info from my package.json:

  • "nuxt": "^2.15.8",
  • "@nuxtjs/composition-api": "^0.33.1",
  • "@storyblok/nuxt-2": "^1.1.0",
  • "core-js": "^3.19.3",

I included the composition-api like this

modules: [
  '@nuxtjs/composition-api/module',
  ...
],

On Stackoverflow there are others who have this issue with node-fetch, but I don't have this dependency installed.

I could update from @nuxtjs/composition-api to Nuxt Bridge, but it's a lot of changes and I am not sure it helps, or my code even works with Bridge.


Solution

  • Downgrading to @nuxtjs/composition-api version 0.29.3 solved the issue. Version 0.30.0 starts to use mjs which seems to not be compatible with the current version of @storyblok/nuxt-2.