Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ncc build fails with bun when node isn't installed #1132

Open
benjiewheeler opened this issue Oct 27, 2023 · 0 comments
Open

ncc build fails with bun when node isn't installed #1132

benjiewheeler opened this issue Oct 27, 2023 · 0 comments

Comments

@benjiewheeler
Copy link

When using ncc in a docker build with the oven/bun image, the build fails with the following error:

1.687 error: Module build failed (from ../tmp/@vercel/ncc--bunx/node_modules/@vercel/ncc/dist/ncc/loaders/ts-loader.js):
1.687 Error: Could not load TypeScript compiler with NPM package name `/tmp/@vercel/ncc--bunx/node_modules/@vercel/ncc/dist/ncc/typescript.js`. Are you sure it is correctly installed?
1.687     at loader (/tmp/@vercel/ncc--bunx/node_modules/@vercel/ncc/dist/ncc/loaders/ts-loader.js.cache.js:32:279744)
1.687       at /tmp/@vercel/ncc--bunx/node_modules/@vercel/ncc/dist/ncc/index.js.cache.js:38:3792429
1.687       at /tmp/@vercel/ncc--bunx/node_modules/@vercel/ncc/dist/ncc/index.js.cache.js:38:792441
1.687       at _done (:9:0)
1.687       at processTicksAndRejections (:55:76)
1.687 
------
Dockerfile:12
--------------------
  10 |     COPY src/ ./src
  11 |     
  12 | >>> RUN bun x @vercel/ncc build ./src/index.ts -o ./dist
  13 |     
  14 |     FROM oven/bun:1.0.6-alpine as run
--------------------
ERROR: failed to solve: process "/bin/sh -c bun x @vercel/ncc build ./src/index.ts -o ./dist" did not complete successfully: exit code: 1

Adding nodejs to the Dockerfile solves this issue:

# build-stage
FROM oven/bun:1.0.6-alpine as build

# vvvvvvvvvvvvvvvvvvvvvvv
# uncommenting this line solves the issue
# RUN apk add --no-cache nodejs
# ^^^^^^^^^^^^^^^^^^^^^^^

WORKDIR /build

# copy package.json & lockfile
COPY package.json bun.lockb ./

# install dependencies
RUN bun install

# add source code
COPY tsconfig.json ./
COPY src/ ./src

# build
RUN bun x @vercel/ncc build ./src/index.ts -o ./dist

# run stage
FROM oven/bun:1.0.6-alpine as run

WORKDIR /app

# copy the files from the build stage
COPY --from=build /build/package.json /build/bun.lockb ./
COPY --from=build /build/dist/ ./dist

# app go brrrrrr
CMD [ "/bin/sh", "-c", "bun run dist/index.js 2>&1" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant