Skip to content

yarn build: run scripts failed in package.json #3154

Open

Description

@smile2mylife

Steps

  1. npm install node-gyp -g
  2. yarn init
  3. create hello.cc, binding.gyp, index.js

package.json

  "scripts": {
    "build": "node-gyp configure && node-gyp build",
    "run:demo": "node index.js"
  },

run directly success

node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@11.2.0

but run from yarn failed

yarn build
yarn run v1.22.22
$ node-gyp configure && node-gyp build

E:\lab\node-gyp-demo>if not defined npm_config_node_gyp (node "C:\programs\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure )  else (node "" configure ) 
C:\programs\nodejs\node_modules\npm\node_modules\node-gyp\lib\log.js:80
    log.pause()
        ^

TypeError: Cannot read properties of undefined (reading 'pause')
    at new Logger (C:\programs\nodejs\node_modules\npm\node_modules\node-gyp\lib\log.js:80:9)
    at Object.<anonymous> (C:\programs\nodejs\node_modules\npm\node_modules\node-gyp\lib\log.js:164:11)
    at Module._compile (node:internal/modules/cjs/loader:1562:14)
    at Object..js (node:internal/modules/cjs/loader:1699:10)
    at Module.load (node:internal/modules/cjs/loader:1313:32)
    at Function._load (node:internal/modules/cjs/loader:1123:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1335:12)
    at require (node:internal/modules/helpers:136:16)

Node.js v22.13.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Activity

  1. cclauss commented on Apr 13, 2025

    @cclauss
    Contributor

    Please do not take pictures of logs. Instead, you can just paste in the text of the log, which is searchable and does not cut off file paths at just the wrong moment.

  2. changed the title [-]run scripts failed in package.json[/-] [+]yarn build: run scripts failed in package.json[/+] on Apr 13, 2025
  3. lukekarrys commented on Apr 16, 2025

    @lukekarrys
    Member

    @smile2mylife Can you try logging what version of node-gyp is available when run with yarn? You should be able to add a new package.json script like { "node-gyp-version": "node-gyp --version" } and then run it with yarn node-gyp-version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions