3

I've just install the recent node-gyp and I'm using node v4.4.7.

When trying to install node module i'm getting this weird error:

> node-gyp rebuild

make: Entering directory `/node_modules/libxml-xsd/node_modules/libxmljs-mt/build'
  CXX(target) Release/obj.target/xmljs/src/libxmljs.o
make: g++: Command not found
make: *** [Release/obj.target/xmljs/src/libxmljs.o] Error 127
make: Leaving directory `/node_modules/libxmljs-mt/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.19.0-32-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /node_modules/libxml-xsd/node_modules/libxmljs-mt
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok 
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! weird error 1
npm ERR! not ok code 0

Please note that in the error it's written i'm using node 0.10.25. When I type:

node -v

I get:

v4.4.7

Can someone help?

1
  • It's common problem. You must configure node-gyp - github.com/nodejs/node-gyp or try node-pre-gyp. Commented Jul 21, 2016 at 14:32

4 Answers 4

4

First try to install build-essential by running the following.

sudo apt install build-essential

If it says that it is already installed, then first remove gcc, g++, build-essential and install build-essential. To do the same, run this.

sudo apt remove gcc g++ build-essential && sudo apt update && sudo apt install build-essential

Hopefully it solves your problem.

Sign up to request clarification or add additional context in comments.

1 Comment

installing build-essential solved the problem for me. thanks :)
1

Look at the error message:

make: g++: Command not found

It isn't complaining that your version of Node is too old. It is complaining that it can't find a C++ compiler. You need to install g++ so it can compile the C++ components of the module.

4 Comments

can you share how I should install it ?
when trying to "sudo apt-get install g++" i'm getting this error: Reading package lists... Error! E: Unable to parse package file /var/lib/apt/lists/mirror.isoc.org.il_pub_ubuntu_dists_trusty_universe_i18n_Translation-en (1) E: Problem opening /var/lib/apt/lists/mirror.isoc.org.il_pub_ubuntu_dists_trusty-updates_main_binary-amd64_Packages E: The package lists or status file could not be parsed or opened.
I've used the following commands and problem not fixed! I'm getting the same error: sudo rm -r /var/lib/apt/lists/*, sudo apt-get update, sudo apt-get install g++, sudo npm install -g node-gyp, sudo apt-get install build-essential, sudo npm install libxml-xsd --save
g++ has the newest version: INPUT: sudo apt-get install g++ OUTPUT: Reading package lists... Done Building dependency tree Reading state information... Done g++ is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 183 not upgraded.
1

RedHat users needs to have g++ compilers. Use the following command to install.

dnf install gcc-c++

1 Comment

Men you saved my life, the only thing that works for me
1

It was very useful for me, like this:

For AL2 (Amazon Linux 2) Users

yum install gcc-c++ -y

1 Comment

If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.