6 months ago
My node js server uses SQLite3 in development. When I try to deploy to Railway I get the errors:
… node_sqlite3.node: invalid ELF header … Could not find any Python installation to use
ChatGPT says: sqlite3—like the old native bcrypt—bundles a binary .node file that must match the CPU, OS and C library in the container.
Railway’s default Nixpacks image doesn’t have a build tool-chain or Python, so when it tries to fall back to compiling one for Linux you get: [the above errors ^^^^^^]
I'd rather not take the time to switch the SQL to PostgreSQL which is one of ChatGPT's main suggestions. Had no success with the other ChatGPT suggestions so far. Anyone know how I can get the project deployed while keeping the SQLite code?
2 Replies
6 months ago
ChatGPT should never be the first place to look.
Can you share your repository?
6 months ago
Try using Docker instead of Railway's buildpacks. Add a file named "Dockerfile" in your project root, with the contents:
FROM node:latest-alpine # Replace `latest` with the Node.js version that you use (check with `node --version`)
WORKDIR /app
RUN apk add --update python3 make g++\
&& rm -rf /var/cache/apk/* # This ensures Python is available to the Node.js installation
COPY package.json package.json
COPY package-lock.json package-lock.json
RUN npm ci # Install dependencies from package.json
COPY . . # This copies most of the files next to the Dockerfile into the image (including any sensitive information, so put anything in your .gitignore into .dockerignore as well!)
CMD ["node", "server.js"] # or main.js or whateverhttps://www.docker.com/blog/getting-started-with-docker-using-node-jspart-i/
Status changed to Solved noahd • 2 months ago