node-gradle / node-gradle/gradle-node-plugin

NixOS: Receiving an error of command failed when attempting to utilize the plugin on a fresh install.

Open
#286 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

musl / nixos / alpine workaround exists
Dominant language
Groovy
Stars
677
Forks
120
PR merge metrics
No merged PRs in 30d

Description

I'm attempting to use the plugin with gradle version of 7.6 but I'm running into the error shown below.

Task :b:npmInstall FAILED
npm ERR! code 127
npm ERR! path /home/dev/a/b/c/node_modules/@swc/core
npm ERR! command failed
npm ERR! command sh -c node postinstall.js
npm ERR! sh: line 1: /home/dev/a/b/c/.gradle/nodejs/node-v18.17.1-linux-x64/bin/node: cannot execute: required file not found

npm ERR! A complete log of this run can be found in: x.log

Contents of x.log file

verbose stack Error: command failed
1083 verbose stack     at ChildProcess.<anonymous> (/home/dev/a/b/c/.gradle/nodejs/node-v18.17.1-linux-x64/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
1083 verbose stack     at ChildProcess.emit (node:events:514:28)
1083 verbose stack     at maybeClose (node:internal/child_process:1091:16)
1083 verbose stack     at Socket.<anonymous> (node:internal/child_process:449:11)
1083 verbose stack     at Socket.emit (node:events:514:28)
1083 verbose stack     at Pipe.<anonymous> (node:net:323:12)
1084 verbose pkgid @swc/core@1.3.81
1085 verbose cwd /home/dev/a/b/c
1086 verbose Linux 6.1.49
1087 verbose node v18.17.1
1088 verbose npm  v9.6.7
1089 error code 127
1090 error path /home/dev/a/b/c/node_modules/@swc/core
1091 error command failed
1092 error command sh -c node postinstall.js
1093 error sh: line 1: /home/dev/a/b/c/.gradle/nodejs/node-v18.17.1-linux-x64/bin/node: cannot execute: required file not found
1094 verbose exit 127
1095 timing npm Completed in 11972ms
1096 verbose unfinished npm timer reify 1693431512159
1097 verbose unfinished npm timer reify:build 1693431523676
1098 verbose unfinished npm timer build 1693431523676
1099 verbose unfinished npm timer build:deps 1693431523676
1100 verbose unfinished npm timer build:run:postinstall 1693431523683
1101 verbose unfinished npm timer build:run:postinstall:node_modules/@swc/core 1693431523683
1102 verbose unfinished npm timer build:run:postinstall:node_modules/esbuild 1693431523711
1103 verbose code 127
1104 error A complete log of this run can be found in: /home/dev/.npm/_logs/2023-08-30T21_38_31_938Z-debug-0.log

contents of the build.gradle.kts file

import com.github.gradle.node.npm.task.NpmTask

plugins {
    id("com.github.node-gradle.node")
}

// Configure the plugin to download and use specific Node version
node {
    version.set("18.17.1")
    npmInstallCommand.set("install")
    download.set(true)
}

// Register NpmTask that will do what "npm run build" command does.
tasks.register<NpmTask>("npmBuild") {
    dependsOn(listOf("npmInstall"))
    npmCommand.set(listOf("run","build"))
    inputs.dir("src")
}

tasks.named<NpmTask>("npmInstall") {
    args.set(listOf("--loglevel verbose"))
}

Gradle output shows error caused by statement shown below

Caused by: org.gradle.process.internal.ExecException: Process 'command '/home/dev/a/b/c/.gradle/nodejs/node-v18.17.1-linux-x64/bin/npm'' finished with non-zero exit value 127

Thank you in advance!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported build.gradle.kts configuration and reproduce the fresh-install npmInstall failure on NixOS using Node.js 18.17.1. Trace why the downloaded .gradle/nodejs executable cannot run and verify that the plugin's npmInstall task completes successfully without exit code 127.

Written by the indexing model from the issue text.

Assessment

Tech stack
nixos, nodejs
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.