Skip to content

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

@smile2mylife

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 [email protected]

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.

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