Build Nuxt 3 app in Docker using npm
See original GitHub issueEnvironment
Host:
Nuxt CLI v3.0.0-27252861.4f9c87b RootDir: /projects/web/nuxt-test Nuxt project info:
- Operating System:
Linux
- Node Version:
v14.18.1
- Nuxt Version:
3.0.0-27252861.4f9c87b
- Package Manager:
npm
- Bundler:
Vite
- User Config:
nitro
- Runtime Modules:
-
- Build Modules:
-
Inside the Docker building container:
Nuxt CLI v3.0.0-27252861.4f9c87b RootDir: /vue-build Nuxt project info:
- Operating System:
Linux
- Node Version:
v14.18.1
- Nuxt Version:
3.0.0-27252861.4f9c87b
- Package Manager:
npm
- Bundler:
Vite
- User Config:
nitro
- Runtime Modules:
-
- Build Modules:
-
Describe the bug
During the build of my Nuxt 3 app with npm inside the node:lts Docker image, the build fails saying sh: 1: nuxi: not found
. When I do the same with Yarn as the package manager inside the node:lts Docker image, the build works fine and my application can be launched as a Docker container.
Reproduction
- Create a nuxt 3 project app:
npx nuxi init nuxt3-app
- Install the dependencies:
npm install
- Create a
.dockignore
file:
.nuxt
.output
node_modules
- Create a file
Dockerfile
containing the following content:
FROM node:lts as builder
WORKDIR /vue-bd
COPY package*.json ./
RUN npm install --prefer-offline --pure-lockfile --non-interactive --production=false
COPY . .
RUN npm run build
FROM node:lts-alpine
WORKDIR /app
COPY --from=builder /vue-bd/package*.json ./
RUN NODE_ENV=production npm install --pure-lockfile --non-interactive --production=true
COPY --from=builder /vue-bd/.output ./.output
EXPOSE 3000
ENTRYPOINT [ "npm", "run", "start" ]
- Build the image:
docker build . -t=my-nuxt-image
Additional context
By replacing every occurrence of npm by its equivalent in Yarn, the Docker image builds perfectly. Also, by deleting package-lock.json, the build also completes.
Logs
Step 7/15 : RUN npm run build
---> Running in 1aa78248f392
> @ build /vue-bd
> nuxi build
sh: 1: nuxi: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! @ build: `nuxi build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-10-25T16_21_08_211Z-debug.log
The command '/bin/sh -c npm run build' returned a non-zero code: 1
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to deploy a NUXT.JS app via NPM and docker?
Open the Dockerfile with your preffered editor and paste the code below: FROM node:14.4.0-alpine3.12 AS BASE; # Create app directory ...
Read more >How to create a dockerized Nuxt 3 development environment
Now, cd nuxt-app or open the folder in your favorite IDE. Instead of installing the packages on our local machine, we want to...
Read more >Get Started Running NuxtJS in a Docker Container
This quickstart guide provides a basic introduction to the NuxtJS progressive framework running on docker. This is a great starting point if you...
Read more >Deploying a Nuxt.js App with Docker - JonathanMH
Deploying a Nuxt.js App with Docker. Let's check out how you can deploy your Nuxt.js app, including server side rendering, with Docker.
Read more >Dockerize Nuxt.js
Create a docker image of Nuxt.js app with Nginx proxy server and MySQL. ... Docker compose section. FROM node:12.16.3-alpine3.9 RUN mkdir -p ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@danielroe so sorry to disturb you.
Here my config, and it works.
I also meet this problem, nuxi not found, https://github.com/nuxt/framework/issues/4737