nixpacks
nixpacks copied to clipboard
Node projects that require node-gyp fail to build without custom nixpacks config
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
Node projects that require node-gyp fail because python
and build-essential
are missing.
To reproduce
- Clone https://github.com/ModupeD/Gatsby-site (this app is a new gatsby app created with
gatsby new
) - Delete
nixpacks.toml
-
nixpacks build . --install-cmd 'npm install' --build-cmd 'gastby build' --start-cmd 'echo 0'
Expected behavior
App builds successfully
Environment
nixpacks 1.6.0
Workaround
add nixpacks.toml
[phases.setup]
nixPkgs = ['...','python311']
aptPkgs = ['build-essential']
To solve this, create nixpacks.toml
in your repo:
providers = ["node", "python"]
the issue still persists
#11 [stage-0 7/11] RUN --mount=type=cache,id=gsoss4w-/root/bun,target=/root/.bun bun i --no-save
#11 0.888 [0.66ms] ".env"
#11 0.905 bun install v1.1.9 (bb13798d)
#11 70.35 node:events:495
#11 70.35 throw er; // Unhandled 'error' event
#11 70.35 ^
#11 70.35
#11 70.35 Error: spawn node-gyp ENOENT
#11 70.35 at ChildProcess._handle.onexit (node:internal/child_process:284:19)
#11 70.35 at onErrorNT (node:internal/child_process:477:16)
#11 70.35 at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
#11 70.35 Emitted 'error' event on ChildProcess instance at:
#11 70.35 at ChildProcess._handle.onexit (node:internal/child_process:290:12)
#11 70.35 at onErrorNT (node:internal/child_process:477:16)
#11 70.35 at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
#11 70.35 errno: -2,
#11 70.35 code: 'ENOENT',
#11 70.35 syscall: 'spawn node-gyp',
#11 70.35 path: 'node-gyp',
#11 70.35 spawnargs: [ 'rebuild' ]
#11 70.35 }
#11 70.35
#11 70.35 Node.js v18.20.2
#11 70.35
#11 70.35 error: install script from "usb" exited with 1
#11 ERROR: process "/bin/bash -ol pipefail -c bun i --no-save" did not complete successfully: exit code: 1
------
> [stage-0 7/11] RUN --mount=type=cache,id=gsoss4w-/root/bun,target=/root/.bun bun i --no-save:
70.35 errno: -2,
70.35 code: 'ENOENT',
70.35 syscall: 'spawn node-gyp',
70.35 path: 'node-gyp',
70.35 spawnargs: [ 'rebuild' ]
70.35 }
70.35
70.35 Node.js v18.20.2
70.35
70.35 error: install script from "usb" exited with 1
------
Dockerfile:20
--------------------
18 | ENV NIXPACKS_PATH /app/node_modules/.bin:$NIXPACKS_PATH
19 | COPY . /app/.
20 | >>> RUN --mount=type=cache,id=gsoss4w-/root/bun,target=/root/.bun bun i --no-save
21 |
22 | # build phase
--------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c bun i --no-save" did not complete successfully: exit code: 1
Error: Docker build failed
[2024-Jun-10 14:00:48.693567] Deployment failed. Removing the new version of your application.
@pranavp10 not sure if you ever solved the issue, it has been one and half months but... So, today I stumbled on the same issue when trying to deploy a bun application in coolify through nixpacks. After some trial and error ended up with that working with the following settings:
- Creating
nixpacks.toml
and addingproviders = ["...", "python"]
to install python, which is necessary tonode-gyp
- Adding
node-gyp
as a dependency withbun install node-gyp
For anyone that ends up here with the same issue, try the steps above.