nixpacks icon indicating copy to clipboard operation
nixpacks copied to clipboard

Node projects that require node-gyp fail to build without custom nixpacks config

Open flybayer opened this issue 1 year ago • 3 comments

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

  1. Clone https://github.com/ModupeD/Gatsby-site (this app is a new gatsby app created with gatsby new)
  2. Delete nixpacks.toml
  3. 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']

flybayer avatar May 25 '23 21:05 flybayer

To solve this, create nixpacks.toml in your repo:

providers = ["node", "python"]

iamEvanYT avatar May 30 '24 21:05 iamEvanYT

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 avatar Jun 10 '24 14:06 pranavp10

@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 adding providers = ["...", "python"] to install python, which is necessary to node-gyp
  • Adding node-gyp as a dependency with bun install node-gyp

For anyone that ends up here with the same issue, try the steps above.

Dinip avatar Jul 28 '24 21:07 Dinip