Deploy a Nuxt 3 App

I am trying to deploy a Nuxt 3 app to Fly and not having any luck.

Steps:

  1. Create a Nuxt app using npx nuxi@latest init my-app
  2. Run fly launch
  3. Run npx --yes @flydotio/dockerfile@latest
    based on advice from this post - if I do not do this I get a yarn error
    Run a NuxtJS App Docs

This seems to update the Docker file for Nuxt

Then I run fly deploy but I get this error

 > [build 6/6] RUN yarn install --production=true:                                                                                                                                                                                                
#14 0.481 yarn install v1.22.19                                                                                                                                                                                                                   
#14 0.562 [1/4] Resolving packages...                                                                                                                                                                                                             
#14 0.890 [2/4] Fetching packages...                                                                                                                                                                                                              
#14 0.903 warning Pattern ["wrap-ansi@^7.0.0"] is trying to unpack in the same destination "/usr/local/share/.cache/yarn/v6/npm-wrap-ansi-cjs-7.0.0-67e145cff510a6a6984bdf1152911d69d2eb9e43-integrity/node_modules/wrap-ansi-cjs" as pattern ["wrap-ansi-cjs@npm:wrap-ansi@^7.0.0"]. This could result in non-deterministic behavior, skipping.
#14 1.289 warning vscode-languageclient@7.0.0: The engine "vscode" appears to be invalid.
#14 1.301 [3/4] Linking dependencies...
#14 1.303 warning " > @nuxt/devtools@1.0.0-beta.0" has unmet peer dependency "vite@*".
#14 1.303 warning "@nuxt/devtools > @nuxt/devtools-kit@1.0.0-beta.0" has unmet peer dependency "vite@*".
#14 1.303 warning "@nuxt/devtools > vite-plugin-inspect@0.7.40" has unmet peer dependency "vite@^3.1.0 || ^4.0.0".
#14 1.303 warning "@nuxt/devtools > vite-plugin-vue-inspector@3.7.2" has unmet peer dependency "vite@^3.0.0-0 || ^4.0.0-0".
#14 2.874 [4/4] Building fresh packages...
#14 2.896 $ nuxt prepare
#14 2.908 /bin/sh: 1: nuxt: not found
#14 2.919 error Command failed with exit code 127.
#14 2.919 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

This is my Docker file

# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired

ARG NODE_VERSION=18.0.0

FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="Node.js"

# Node.js app lives here

WORKDIR /app

# Set production environment

ENV NODE_ENV="production"

# Throw-away build stage to reduce size of final image

FROM base as build

# Install packages needed to build node modules

RUN apt-get update -qq && \

apt-get install -y build-essential pkg-config python

# Install node modules

COPY --link .npmrc package.json yarn.lock ./

RUN yarn install --frozen-lockfile --production=false

# Copy application code

COPY --link . .

# Build application

RUN yarn run build

# Remove development dependencies

RUN yarn install --production=true

# Final stage for app image

FROM base

# Copy built application

COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime

EXPOSE 3000

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

Are there any other more detailed instructions to deploy a Nuxt app to Fly?

Does this help: Dependencies · Fly Docs ?

For future reference, the issue here is that npx nuxi@latest init my-app creates a package.json with nuxt specified in “devDependencies”. Then, RUN yarn install --production=true in the Dockerfile removes all “devDependencies”, including Nuxt.

For NPM you can you use RUN npm ci --include=dev. I also had to update the last two commands

# Copy built application
COPY --from=build /app/.output /app

# Start the server by default, this can be overwritten at runtime
CMD [ "node", "/app/server/index.mjs" ]