@sapphire/type does not work with Bun

Hello! I was trying to get my Sapphire application up and running on my server, however I was greeted with this error:
silver-wolf | $ bun src/index.ts
silver-wolf | Error when loading '/usr/src/app/src/commands/utils/eval.ts': 17 | var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
silver-wolf | 18 | var getFilename = /* @__PURE__ */ __name(() => fileURLToPath(import.meta.url), "getFilename");
silver-wolf | 19 | var getDirname = /* @__PURE__ */ __name(() => path.dirname(getFilename()), "getDirname");
silver-wolf | 20 | var __dirname = /* @__PURE__ */ getDirname();
silver-wolf | 21 | var bindingPath = nodePreGyp.find(resolve(join(__dirname, "..", "..", "./package.json")));
silver-wolf | 22 | var { getPromiseDetails, getProxyDetails } = __require(bindingPath);
silver-wolf | ^
silver-wolf | TypeError: /usr/src/app/node_modules/@sapphire/type/prebuild/type-node-v127-linux-x64-glibc-2.29/type.node: undefined symbol: _ZNK2v85Value9IsPromiseEv
silver-wolf | at /usr/src/app/node_modules/@sapphire/type/dist/esm/index.mjs:22:46
silver-wolf |
silver-wolf | [INFO] Logged in as Silver Wolf (production mode)
silver-wolf | $ bun src/index.ts
silver-wolf | Error when loading '/usr/src/app/src/commands/utils/eval.ts': 17 | var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
silver-wolf | 18 | var getFilename = /* @__PURE__ */ __name(() => fileURLToPath(import.meta.url), "getFilename");
silver-wolf | 19 | var getDirname = /* @__PURE__ */ __name(() => path.dirname(getFilename()), "getDirname");
silver-wolf | 20 | var __dirname = /* @__PURE__ */ getDirname();
silver-wolf | 21 | var bindingPath = nodePreGyp.find(resolve(join(__dirname, "..", "..", "./package.json")));
silver-wolf | 22 | var { getPromiseDetails, getProxyDetails } = __require(bindingPath);
silver-wolf | ^
silver-wolf | TypeError: /usr/src/app/node_modules/@sapphire/type/prebuild/type-node-v127-linux-x64-glibc-2.29/type.node: undefined symbol: _ZNK2v85Value9IsPromiseEv
silver-wolf | at /usr/src/app/node_modules/@sapphire/type/dist/esm/index.mjs:22:46
silver-wolf |
silver-wolf | [INFO] Logged in as Silver Wolf (production mode)
Here's my package.json file:
{
"name": "silver-wolf",
"type": "module",
"main": "src/index.ts",
"scripts": {
"dev": "NODE_ENV=development tsx --env-file .env src/index.ts",
"start": "bun src/index.ts"
},
"dependencies": {
"@sapphire/framework": "^5.3.1",
"@sapphire/plugin-editable-commands": "^4.0.3",
"@sapphire/plugin-hmr": "^3.0.2",
"@sapphire/plugin-subcommands": "^7.0.1",
"@sapphire/stopwatch": "^1.5.4",
"@sapphire/type": "^2.5.1",
"@sapphire/utilities": "^3.18.1",
"discord.js": "^14.16.3"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@types/bun": "^1.1.13",
"tsx": "^4.19.2"
},
"trustedDependencies": ["@biomejs/biome", "@sapphire/type", "esbuild"]
}
{
"name": "silver-wolf",
"type": "module",
"main": "src/index.ts",
"scripts": {
"dev": "NODE_ENV=development tsx --env-file .env src/index.ts",
"start": "bun src/index.ts"
},
"dependencies": {
"@sapphire/framework": "^5.3.1",
"@sapphire/plugin-editable-commands": "^4.0.3",
"@sapphire/plugin-hmr": "^3.0.2",
"@sapphire/plugin-subcommands": "^7.0.1",
"@sapphire/stopwatch": "^1.5.4",
"@sapphire/type": "^2.5.1",
"@sapphire/utilities": "^3.18.1",
"discord.js": "^14.16.3"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@types/bun": "^1.1.13",
"tsx": "^4.19.2"
},
"trustedDependencies": ["@biomejs/biome", "@sapphire/type", "esbuild"]
}
... and my Dockerfile:
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:alpine AS base
WORKDIR /usr/src/app

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN apk add --no-cache python3 make g++
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile

# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .

# [optional] tests & build
ENV NODE_ENV=production
RUN bun test

# copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/ .

# run the app
USER bun
ENTRYPOINT [ "bun", "start" ]
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:alpine AS base
WORKDIR /usr/src/app

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN apk add --no-cache python3 make g++
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile

# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .

# [optional] tests & build
ENV NODE_ENV=production
RUN bun test

# copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/ .

# run the app
USER bun
ENTRYPOINT [ "bun", "start" ]
Not sure what I'm doing wrong here. I'd appreciate any help. Thanks!
4 Replies
Favna
Favna4d ago
@sapphire/type uses NodeJS internals so yeah that makes sense. Not much we can do about it unless someone were to rewrite it to a language like Rust. (prs welcome)
SirH
SirH4d ago
someone called?
Favna
Favna4d ago
yeah when will you
SirH
SirH3d ago
I have the energy for tonight, so- I'll see what I can do in a bit This will be much more complicated than I previously thought cause Aura and I discussed it, she apparently had a bit of a tough roadblock that I can try to figure out but it will certainly not be an easy task :kek:
Want results from more Discord servers?
Add your server