question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[vite] error while transforming /app/client/vite.config.ts with esbuild in Docker image

See original GitHub issue

Describe the bug

Following error when trying to run vite build in a docker container. I tried to convert the config file to a JS file but then it throws an error on my main.ts. On my (windows) development pc the build command works perfectly.

> vite build --debug

vite v1.0.0-rc.4
[vite] error while transforming /app/client/vite.config.ts with esbuild:
Error: The service was stopped
    at /app/client/node_modules/esbuild/lib/main.js:405:31
    at Socket.afterClose (/app/client/node_modules/esbuild/lib/main.js:331:7)
    at Socket.emit (events.js:326:22)
    at endReadableNT (_stream_readable.js:1252:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
2020-10-03T10:43:26.410Z vite:esbuild options used:  {
  loader: 'ts',
  sourcemap: true,
  sourcefile: '/app/client/vite.config.ts',
  target: 'es2020',
  jsxFactory: undefined,
  jsxFragment: undefined
}
2020-10-03T10:43:26.422Z vite:config env mode: production
2020-10-03T10:43:26.424Z vite:config env: { VITE_API_URL: 'http://localhost:3000' }
2020-10-03T10:43:26.424Z vite:config config resolved in 116ms
Building for production...
[vite] Build errored out.
Error: Could not resolve entry module (index.html).
    at error (/app/client/node_modules/rollup/dist/shared/rollup.js:5210:30)
    at ModuleLoader.loadEntryModule (/app/client/node_modules/rollup/dist/shared/rollup.js:18295:16)
    at async Promise.all (index 0) {
  code: 'UNRESOLVED_ENTRY'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bitcoin-warzone-client@0.0.1 build: `vite build --debug`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bitcoin-warzone-client@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Vite: 1.0.0-rc.4 Docker image: https://hub.docker.com/_/node (tried multiple)

Dockerfile:

#BUILD
FROM node:14-alpine AS builder

WORKDIR /app

COPY ./server/package*.json ./server/
COPY ./client/package*.json ./client/

RUN cd server && npm install
RUN cd client && npm install

COPY . .

RUN cd server && npm run build
RUN cd client && npm run build

#SERVE
FROM node:14-alpine

WORKDIR /app

COPY --from=builder /app ./

EXPOSE 3000

WORKDIR /app/server

CMD ["npm", "run", "start:prod"]

Reproduction/System Info

I have tried tens of different docker containers with node installed, they all give me this error.

Logs (Optional if provided reproduction)

I ran with the --debug flag.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
nazmifeerozcommented, Apr 22, 2021

I managed to get this work by running

RUN node node_modules/esbuild/install.js

before the build command.

3reactions
underfincommented, Oct 4, 2020

You should add index.html into your container.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I keep getting an error in Vite version 3.2.4 which says `[vite ...
Vite build fails with esbuild error · error while transforming /app/client/vite.config.ts with esbuild in Docker image.
Read more >
BundlingOptions — AWS Cloud Development Kit 1.183.0 ...
A custom bundling Docker image. This image should have esbuild installed globally. If you plan to use nodeModules it should also have npm...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found