'Nuxt 3 won't run after importing composition api module

I just started a fresh project with Nuxt 3. Installed only Sass and tailwind packages, everything worked fine. Then I added composition-api and it didn't start anymore. Can't find any fixes on this issue.

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

then when I run 'npm run dev':

ERROR Cannot start nuxt: Cannot read properties of undefined (reading 'resolveModule') 14:27:08

at Object.compositionApiModule2 (node_modules@nuxtjs\composition-api\dist\module\index.js:124:85)

Does someone here have an idea on how to fix? I already tried removing node modules and package.lock and reinstalling, but it didn't help.



Solution 1:[1]

Nuxt 3 does not need the @nuxtjs/composition-api module. You can just use the composition api as you know it from Vue 3.

A short TypeScript example of the composition api in Nuxt 3:

<script lang="ts" setup>
import { onMounted } from "#imports";

onMounted(() => {
  console.log("Hello World!");
});
</script>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MysteriousPerson