0

I have successfully installed Node.js, now I want to install the websocket module found here: https://github.com/Worlize/WebSocket-Node

From the root user, I have run the following command:

 npm install websocket 

The error thrown is:

[websocket v1.0.7]

Native code compile failed!! On Windows, native extensions require Visual Studio and Python. On Unix, native extensions require Python, make and a C++ compiler. Start npm with --websocket:verbose to show compilation output (if any). 

What commands should I issue to install this websocket module and its requirements?

Edit: When I run sudo apt-get install gcc make

I get this message:

Reading package lists... Done Building dependency tree Reading state information... Done gcc is already the newest version. gcc set to manually installed. make is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 44 not upgraded.

And the same error when trying to install WebSocket.

4 Answers 4

2

If you see the install.js, this error is because you got problems with node-gyp. Try "sudo npm install -g node-gyp" and run your commands again.

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

Comments

1

Make sure that you have installed python, make and gcc. Python should be already installed by default. You can install gcc and make as root with command:

apt-get install gcc make 

4 Comments

Bizarre, I'm still getting the same error as above. I'll add to the original post.
The same error occurs, additionally I have tried the -g and link commands.
Can you try to install it with this command: npm install websocket --websocket:verbose Then you should see better error message.
Thank you! I rebooted the server and it worked. However I'm unable to find the websocket module by running on my other user. I know why, and I'm going to reinstall node properly by resetting my VPS. This has been a great learning experience, thanks again.
1
apt-get g++ 

fixed my problem, very nice!

Comments

0

My problem: python version. I have installed python 2.4.3 instead python 2.7 (required for websocket).

I install python2.7 with make altinstall and create a symbolic link for replace python script:

ln -s /usr/local/bin/python2.7 /usr/bin/python 

And works for me:

# npm install websocket --websocket:verbose [websocket v1.0.8] Attempting to compile native extensions. gyp http GET http://nodejs.org/dist/v0.10.15/node-v0.10.15.tar.gz gyp http 200 http://nodejs.org/dist/v0.10.15/node-v0.10.15.tar.gz make: Entering directory `********/node_modules/websocket/build' CXX(target) Release/obj.target/validation/src/validation.o SOLINK_MODULE(target) Release/obj.target/validation.node SOLINK_MODULE(target) Release/obj.target/validation.node: Finished COPY Release/validation.node CXX(target) Release/obj.target/xor/src/xor.o SOLINK_MODULE(target) Release/obj.target/xor.node SOLINK_MODULE(target) Release/obj.target/xor.node: Finished COPY Release/xor.node make: Leaving directory `*******/node_modules/websocket/build' [websocket v1.0.8] Native extension compilation successful! 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.