composition-api: Issue: Cannot find module '@vue/composition-api'

๐Ÿ› The bug If you launch a built application with only production dependencies without dev you will get that error above or I donโ€™t understand what itโ€™s mean configuration option buildModules.

๐Ÿ› ๏ธ To reproduce Steps to reproduce the behavior:

  1. Create simple application via yarn create nuxt-app
  2. Add devDependencies via yarn add -D @nuxtjs/composition-api and add this dependency to buildModules in nuxt.config.js file
  3. Run yarn build
  4. Clean node_modules directory and after that run NODE_ENV=production yarn
  5. Run yarn start and open browser
  6. See error

๐ŸŒˆ Expected behaviour Start the application without errors.

โ„น๏ธ Additional context Error Dockerfile for reproduce problem

FROM node:latest as builder

WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn

COPY . ./

RUN yarn build

FROM node:alpine

WORKDIR /app
COPY package.json yarn.lock ./

ENV NODE_ENV=production
RUN yarn

COPY nuxt.config.js ./
COPY --from=builder /app/.nuxt ./.nuxt/
COPY --from=builder /app/static ./static/

EXPOSE 3000

ENV NUXT_HOST=0.0.0.0

ENTRYPOINT [ "yarn", "run" ]
CMD [ "start" ]

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (6 by maintainers)

Commits related to this issue

Most upvoted comments

More info: This (my) bug is from docker with the node:14.14.0-alpine3.12 image. Now I use node:10, itโ€™s work fine ! So, do not use an alpine version of node

@CrazyUmka You will either need to add @vue/composition-api to your transpile array in nuxt.config or ensure it is installed as a production dependency.

{
  transpile: [/@vue[\\/]composition-api/],
}

The transpile solution doesnโ€™t works for me (Cannot find module '@vue/composition-api')

And when I manually install @vue/composition-api@1.0.0-beta.17 (https://github.com/nuxt-community/composition-api/issues/241#issuecomment-693927221 and version founded in requires of @nuxtjs/composition-api) I have this error:

[vue-composition-api] already installed. Vue.use(VueCompositionAPI) should be called only once

What is the good version of @vue/composition-api to install ?

For you information: I use @nuxtjs/composition-api@0.15.0 With Typescript (nuxt-ts) and Docker image node:14.14.0-alpine3.12

Thanks !

@CrazyUmka It should be the Vue composition API in the transpile array.

Thanks, Iโ€™ll try it today. I saw my mistake ๐Ÿ˜…

@CrazyUmka It should be the Vue composition API in the transpile array.