SolidStart and Bun

I think this is still being worked on but if anyone has any tips for getting this going on fly.io

The author of SolidJS said that our detection worked great:

And Bun loves us tooL

If there is anything specific about SolidStart that needs our attention, let us know!

1 Like

Thanks, I saw that tweet, I have a few solidstart apps with pnpm on fly, which is what Ryan is using for the hackernews demos, but bun gives me $ vinxi build file:///app/node_modules/vinxi/bin/cli.mjs:130 await devServer?.close(); ^ SyntaxError: Unexpected token '.' at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18) at async link (internal/modules/esm/module_job.js:42:21)

If you peek at that file, you will see the first line is:

#!/usr/bin/env node

What is likely happening is that your image has a node is version 13 or less, and doesn’t support optional chaining. This probably should be fixed in vinxi, but installing a newer version of node can also be added to your Dockerfile.

Can you confirm that you are using the Dockerfile generated by fly launch?

yes auto-generated Dockerfile, and node > 18 , I did see something about vinxi and optional chaining earlier, will explore further, shall i try adding a line for installing node in the meantime? Thanks

I won’t be able to take a look at this until this afternoon, but just to be clear what I think is happening: if you wanted to deploy using Node, we would have constructed a Dockerfile that loaded a version of Node that matches what you are using in development. But since you are using Bun, we did that for Bun instead. Despite this vinxi build has explicitly called out for Node, and while I’m surprised it worked at all, you are probably getting the version of Node that came with the OS, which is ancient.

Yes, installing a newer version of Node and making sure that it is in your path will get you past this point. That can be tricky.

Ok thanks, I can just switch to pnpm for now though, rather than hassling you about frameworks that are still in beta…

Don’t switch on my account, I want to make this work.

It looks like you were running with 12.22.12 which doesn’t support the optional chaining operator: Node.js ES2015/ES6, ES2016 and ES2017 support

Making the following changes to your Dockerfile will enable you to deploy using Bun:

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential curl ca-certificates node-gyp pkg-config python-is-python3

# Install Node.js
ARG NODE_VERSION=21.6.2
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
    /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
    rm -rf /tmp/node-build-master

Note you need to add both curl and ca-certificates to the apt-get install line, and add the lines to install Node.js. This is only for the build step to complete, none of these packages will be included in your final image.

1 Like

Ok thanks, I’ll give it a go, it won’t let me sign in at the mo

That’s great thanks it works now! not sure where node 12 is coming from - I’ll have a look into what vinxi is doing there with calling node - Thanks for your help.

Debian version 11.9.

The Bun docker image is based on the Debian distribution of Linux. More specifically, Bullseye. Bullseye was first released in July of 2021, and included what was then the LTS version of Node, which was 12.

These are the types of details that you shouldn’t have to worry about. I’m not thrilled with the idea that you have to install Node in order to build a Bun application, but it is what it is, and I’ll look to improve the Dockerfile that we produce to handle this situation.

1 Like

I’ve committed a fix:

I’ll release it after a bit more testing. Meanwhile, I’m pleased to see that you are up and running.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.