node-gyp not found
devlzcode
PROOP

2 months ago

builds have been failing for past week, been trying here and there to fix it but no success. Main issue is node-gyp install script is failing.
I figured adding RAILPACK_BUILD_APT_PACKAGES=python3 g++ make would fix it but didn't work.
Fixed by adding --ignore-scripts to the install command but not sure if thats a solution.

edit: I understand that I could use a Dockerfile as well from reading one of the threads but I believe this is a bug in either railpack or mise so I think it's worth fixing since it's so much less brain power than using a Dockerfile.

edit 2: repro: https://github.com/devlzcode/railpack-bun
start command: bun --cwd packages/app start

$30 Bounty

4 Replies

Railway
BOT

2 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


brody
EMPLOYEE

2 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody about 2 months ago


passos
MODERATOR

2 months ago

Hey, I had no problems deploying your example into my project. All I did was set the root directory to /packages/app and let Railpack handle it. Is your setup different from mine?


robksawyer
FREE

2 months ago

The Problem

  • node-gyp is used to build native Node modules. It needs a build environment (Python 3, make, g++) to compile C++ addons.

  • On Railpack (or similar “zero-config” Bun deployments), the build environment may not be fully present. Setting RAILPACK_BUILD_APT_PACKAGES=python3 g++ makeshould work, but sometimes:

    • The environment isn’t propagated correctly.

    • The install scripts run in a context where these packages aren’t yet available.

  • --ignore-scripts bypasses the node-gyp build step, which “works” but breaks native dependencies (so it’s only a temporary workaround, not a real fix).

To sum it up:

  • Make sure RAILPACK_BUILD_APT_PACKAGES="python3 g++ make" is actually applied before bun install.

  • Consider using railpack.config.mjs to enforce system packages.

  • For stubborn native modules, --use-node or a Dockerfile may be necessary.

Railpack uses this to install system packages before running bun install. Ensure it’s exported correctly

export RAILPACK_BUILD_APT_PACKAGES="python3 g++ make"
bun install
bun --cwd packages/app start
  • Sometimes putting this inline works better:

RAILPACK_BUILD_APT_PACKAGES="python3 g++ make" bun install
  • Make sure you’re not running bun install with --ignore-scripts in production unless you’re sure no native modules are needed.

Maybe use a .bunrc or railpack.config.mjs

If the project uses Railpack config, you can specify build packages there:

// railpack.config.mjs
export default {
  buildAptPackages: ["python3", "g++", "make"],
};

This ensures all builds have the required environment.

Another option is to use --use-node for problematic native modules

Bun has trouble with some Node-native modules. You can force Bun to fallback to Node for these:

bun install --use-node
  • Only do this if your module fails to build under Bun.


passos

Hey, I had no problems deploying your example into my project. All I did was set the root directory to /packages/app and let Railpack handle it. Is your setup different from mine?

devlzcode
PROOP

a month ago

hey I haven't tried this since originally in my experience the way railway root directory works is it discards everything outside of that directory but that doesn't work in a monorepro since we require the root bun.lock for example.


Loading...