Bun 1.0 on railway

I am spinning up a simple bun app with 1 file in it. But for some reason all of my builds are failing. I am using bun build ./index.tsx --outdir ./build from bun's documentation to build. This is my service ID: b741e4ae-cac8-410f-a15a-be6e2551fa96 Any help would be appreciated.
56 Replies
Percy
Percy14mo ago
Project ID: b741e4ae-cac8-410f-a15a-be6e2551fa96
fedev
fedev14mo ago
just directly run index.tsx with bun, it supports typescript
"scripts": {
"start": "bun ./index.tsx"
},
"scripts": {
"start": "bun ./index.tsx"
},
Dylan-The-Villian
And this is the build command or the start?
fedev
fedev14mo ago
start in the package json
fedev
fedev14mo ago
do you have theese empty?
No description
Dylan-The-Villian
I do now, before I had bun build and bun index.ts there
fedev
fedev14mo ago
try adding only start in package and leaving those empty
Dylan-The-Villian
So add, "start package.json" for the start command? Or do I put bun ./index.tsx because I have tried those and they failed
fedev
fedev14mo ago
can you send your package.json?
Dylan-The-Villian
{
"name": "andromeda-backend",
"module": "index.ts",
"type": "module",
"devDependencies": {
"bun-types": "latest"
},
"scripts": {
"start": "bun ./index.tsx"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
{
"name": "andromeda-backend",
"module": "index.ts",
"type": "module",
"devDependencies": {
"bun-types": "latest"
},
"scripts": {
"start": "bun ./index.tsx"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
fedev
fedev14mo ago
have you tried deploying it like this?
Dylan-The-Villian
I have been trying with this package.json the whole time
fedev
fedev14mo ago
have the same settings and it works for me have you initialized with bun init?
root
root14mo ago
If that doesn't work, you could try removing all of your custom configuration. Make sure you've run bun install and are committing your bun.lockb.
Dylan-The-Villian
I have run bun init, and bun run index along with bun install. I have it working just fine on my local. This is the error from railway #10 0.237 /bin/bash: line 1: npm: command not found #10 ERROR: process "/bin/bash -ol pipefail -c npm ci" did not complete successfully: exit code: 127
luna
luna14mo ago
Had bun been updated to 1 in railway yet? I’m still running my own dockerfile because of how out of date it was last time I checked. Also why are you doing a build and not just bun run?
Dylan-The-Villian
Hi, where should I put bun run? In the start command?
luna
luna14mo ago
Yes. That’s what you’re using locally, no?
Dylan-The-Villian
And that would be the start command?
luna
luna14mo ago
Yep. That’s all I use for my bun projects
Dylan-The-Villian
It is still failing with ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm ci" did not complete successfully: exit code: 127
luna
luna14mo ago
There’s something you’re missing here. Npm shouldn’t be getting called? Does it show the bun version in the railway logs by chance?
Dylan-The-Villian
It does not
║ setup │ bun ║

║ start │ bun run index.ts ║

#3 [internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1693872184

#4 [stage-0 1/19] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1693872184@sha256:c90dd7da0f961900970339c955170d2c852fee6ba73ccd2c7895f1999ff92609

#10 [stage-0 6/8] RUN --mount=type=cache,id=s/b741e4ae-cac8-410f-a15a-be6e2551fa96-/root/bun,target=/root/.bun npm ci

> [stage-0 6/8] RUN --mount=type=cache,id=s/b741e4ae-cac8-410f-a15a-be6e2551fa96-/root/bun,target=/root/.bun npm ci:

20 | >>> RUN --mount=type=cache,id=s/b741e4ae-cac8-410f-a15a-be6e2551fa96-/root/bun,target=/root/.bun npm ci
║ setup │ bun ║

║ start │ bun run index.ts ║

#3 [internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1693872184

#4 [stage-0 1/19] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1693872184@sha256:c90dd7da0f961900970339c955170d2c852fee6ba73ccd2c7895f1999ff92609

#10 [stage-0 6/8] RUN --mount=type=cache,id=s/b741e4ae-cac8-410f-a15a-be6e2551fa96-/root/bun,target=/root/.bun npm ci

> [stage-0 6/8] RUN --mount=type=cache,id=s/b741e4ae-cac8-410f-a15a-be6e2551fa96-/root/bun,target=/root/.bun npm ci:

20 | >>> RUN --mount=type=cache,id=s/b741e4ae-cac8-410f-a15a-be6e2551fa96-/root/bun,target=/root/.bun npm ci
This is all it says filtering for bun This is an old project that I am converting to bun, it could be that is the issue. Although I created a new project and it also failed to build
Dylan-The-Villian
It does, I looked at the link and I don't have node in my package.json
luna
luna14mo ago
okay, try using that newer nixpack and see if that helps otherwise you could always add a Dockerfile similar to this. might need to change a few things.
FROM oven/bun

WORKDIR /app

COPY src /app/src
COPY bun.lockb package.json tsconfig.json /app/

RUN bun i

CMD bun run start
FROM oven/bun

WORKDIR /app

COPY src /app/src
COPY bun.lockb package.json tsconfig.json /app/

RUN bun i

CMD bun run start
Dylan-The-Villian
still failing with
Dockerfile:20

-------------------

18 | ENV NIXPACKS_PATH /app/node_modules/.bin:$NIXPACKS_PATH

19 | COPY . /app/.

20 | >>> RUN --mount=type=cache,id=s/b741e4ae-cac8-410f-a15a-be6e2551fa96-/root/bun,target=/root/.bun npm ci

21 |

22 | # build phase

-------------------

ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm ci" did not complete successfully: exit code: 127



Error: Docker build failed
Dockerfile:20

-------------------

18 | ENV NIXPACKS_PATH /app/node_modules/.bin:$NIXPACKS_PATH

19 | COPY . /app/.

20 | >>> RUN --mount=type=cache,id=s/b741e4ae-cac8-410f-a15a-be6e2551fa96-/root/bun,target=/root/.bun npm ci

21 |

22 | # build phase

-------------------

ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm ci" did not complete successfully: exit code: 127



Error: Docker build failed
luna
luna14mo ago
lol why it it using npm 🤦‍♀️ @Brody is the nixpack for bun using npm? 🤔
Dylan-The-Villian
I just added the .toml file, is there a way to change it from there?
Brody
Brody14mo ago
just looks like nixpacks is detecting node instead of bun
luna
luna14mo ago
@.dylangm do you a commited bun lock file in your repo? 🤔
Brody
Brody14mo ago
root
root14mo ago
no
Brody
Brody14mo ago
please follow the 3 steps
Dylan-The-Villian
My browser isn't letting me add it as a bookmarklet, it's just working like a usual bookmark
root
root14mo ago
You dragged the "Download Logs" button to your bookmarks bar?
Dylan-The-Villian
I feel like the link could be more clear for idiots like me
Brody
Brody14mo ago
Drag this link to your bookmarks bar
but hey congrats
luna
luna14mo ago
lol what. nixpacks you're drunk.
║ setup │ bun ║ ║───────────────────────────────║ ║ install │ npm ci ║
root
root14mo ago
hrrrm
Brody
Brody14mo ago
what indeed
root
root14mo ago
You have no custom configuration whatsoever?
Brody
Brody14mo ago
any railway.json?
root
root14mo ago
any nixpacks.toml? anything in the service settings?
luna
luna14mo ago
"maybe" 😅
Dylan-The-Villian
Only added the .toml file luna suggested, [phases.setup] nixpkgsArchive = 'c054b2a07bce2be3b85fed85f45aea6a4b97f5cc'
root
root14mo ago
hmmm
Dylan-The-Villian
There's no railway.json in my project, here is the repo https://github.com/DylanBozarth/Andromeda-Backend
GitHub
GitHub - DylanBozarth/Andromeda-Backend
Contribute to DylanBozarth/Andromeda-Backend development by creating an account on GitHub.
root
root14mo ago
Remove package-lock.json
Brody
Brody14mo ago
i was typing that lol speed
luna
luna14mo ago
the instant brain sync 😆 also you'll likely want to set the port to use process.env.PORT not hardcode it to 2999.
Dylan-The-Villian
Wow, it looks like it worked. So was the package-lock left over from the node project?
luna
luna14mo ago
yep
Dylan-The-Villian
Wow, I tried everything but that because I'm so used to seeing that in a project
Brody
Brody14mo ago
luna is right, this is important, please dont forget
Dylan-The-Villian
Thank you all for your help.
Want results from more Discord servers?
Add your server