简体   繁体   中英

error while node-gyp rebuild

pi@raspberrypi ~ $ sudo node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@1.0.2
gyp info using node@0.10.31 | linux | arm
gyp info spawn python
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/pi/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/root/.node-gyp/0.10.31/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/root/.node-gyp/0.10.31',
gyp info spawn args '-Dmodule_root_dir=/home/pi',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/pi/build'
make: *** No rule to make target 'Release/obj.target/binding/src/binding.o', needed by                     'Release/obj.target/binding.node'. Stop.
make: Leaving directory '/home/pi/build'
gyp ERR! build error 
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Linux 3.12.22+
gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/pi
gyp ERR! node -v v0.10.31
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok

this is my error code.

binding.gyp

{
"targets": [
    {
    "target_name": "binding",
    "sources": ["src/binding.cc"]
    }
  ]
}

I install 'npm make' and I do 'sudo apt-get install python-dev' then maybe installed python2.7 And i install 'sudo apt-get install gcc' i don't understand

make: Entering directory '/home/pi/build'
make: *** No rule to make target 'Release/obj.target/binding/src/binding.o', needed by     'Release/obj.target/binding.node'. Stop.
make: Leaving directory '/home/pi/build'
gyp ERR! build error 
gyp ERR! stack Error: make failed with exit code: 2

what does this sentence mean? why can`ti do?

Are you sure the path src/binding.cc exists? It sounds like the directory or file name is wrong.

Node-Gyp README doc is not very explicit on using binding.gyp .

Understand Node-Gyp config binding.gyp

NODE-GYP DOES NOT KNOW ABOUT YOUR CODE STRUCTURE

node-gyp is just a package to build any native add-on package for nodejs, but it's not tied with any package, therefore their example is universal and lack of details to use it with a package.

  • BUILDING OWN CODES:

When you get the error :

make: *** No rule to make target Release/obj.target/binding/src/binding.o', needed by Release/binding.node'. Stop

that's because you've use their universal template to make it work. But Binding Gyp is used, not for their own internal config, but for Package modules config.

So instead of keywords binding, it might be better to include the real module path with real module .cc files like:

{
  "targets": [
    {
      "target_name": "my-subproject-name",
      "sources": [
        "node_modules/my-subproject-dir/cc/test.cc",
        "node_modules/my-subproject-dir/cc/any-other-cc-file.cc"
      ]
    }
  ]
}

This will fully work if it's your own directory in your project with a single or couple of files to compile.

  • BUILDING PACKAGE CODES:

When building package codes, you don't need to configure binding.gyp yourself because the package comes with its own node_modules/package-name/binding.gyp , and a build and Release directories with files to used with the node-gyp build in node_modules/package-name/build/Release that contains .o and od files to tell node-gyp how what to use and how to build the package.

Go to module Directory:

cd node_modules/package-name
node-gyp build
# or execute a js file if any provided like
node ./install/install.js

SO you don't even have to use : node-gyp configure , but just node-gyp build . Sometimes it's auto-building the package after installing, if that causes error then see if you can stop the auto-build with Env Variables or Config, and go to directory to do it manually. Or look for possibilities in package issues.

You might see a lot of Warnings printed in the console as it goes, but don't worry. If the Process succeed, then the built node file will be created:

node_modules/package-name/build/Release/package-name.node

It's been a while but I've just hit this same issue and it ended up being the nodejs version.

Basically it was using a newer version of nodejs when the node-sass that required node-gyp was in an older release requiring a downgrade of the node version.

Hopefully there was a version list in the project which made easy to promote the nodejs version change from 17 to 14 .

Would be yack fix but worked for me to continue the works

commented line 491 block.

I clicked on error link from vscode. it took me to some v8 files.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM