Sunday, June 05, 2011

Building node.js on Solaris 10

Constantly on the search for new tools and technologies to play with, I wanted to actually try out Node.js on my own machine.

I'm running Solaris 10 (x86), and it didn't quite work out first time. But it was pretty trivial to fix. A couple of tweaks to the configure invocation and a simple patch to make things like isnan and signbit work with a vanilla Solaris 10 install.

So, to build Node on Solaris 10 x86:

First download node-0.4.8 and my node patch. (Yes, the patch to V8 is ugly, and it's likely to be specific to the V8 version and the Solaris rev and gcc version. And don't expect Node or V8 to work on sparc at all.)

Unpack node and apply the patch:

gzcat node-v0.4.8.tar.gz | gtar xf -
gpatch -p0 -i node-v0.4.8.soldiff

Then configure and build:

env CFLAGS=-std=gnu99 ./configure --prefix=/opt/Node --without-ssl
gmake -j 8
gmake install

Replacing /opt/Node with wherever you want to install it. (Somewhere you have permission to write to, obviously.)

You then want to install npm. You will need to have curl for this, although I recommend downloading the install.sh and running it by hand, like so:

env PATH=/opt/Node/bin:$PATH TAR=gtar bash install.sh

This way, it uses the correct version of tar and uses a compatible shell. (It actually invokes curl in the script, so you still need curl installed. That's not hard, or you can find one on the Companion CD.)

To actually use npm you need to continue with the tweaks. For example:

env PATH=/opt/Node/bin:$PATH TAR=gtar npm install express
or, if you want it to install express into the Node tree rather than "." you'll need something like:

env PATH=/opt/Node/bin:$PATH TAR=gtar npm install -g express

14 comments:

Anonymous said...

I downloaded lots of versions from http://node.js.org and tried a few of your packages as well, all for Solaris 10. Every time I try to run npm it says node isn't executable when it is, and when I run node directly it comes back with 'Invalid Argument', even though I am passing in a valid JavaScript file which has been successfully tested with node on Linux and Windows.

Dan said...

I downloaded lots of versions from http://node.js.org and tried a few of your packages as well, all for Solaris 10. Every time I try to run npm it says node isn't executable when it is, and when I run node directly it comes back with 'Invalid Argument', even though I am passing in a valid JavaScript file which has been successfully tested with node on Linux and Windows.

Peter Tribble said...

The most likely thing here is that you're trying to do this on a SPARC system, which won't work - Node (and v8) and the resulting prebuilt SunOS binaries are x86 only.

Anonymous said...

Package adds okay but running:

npm test gives:-
opt/Node/lib/node_modules/npm/node_modules/npmconf/config-defs.js:349
, "local-address" : Object.keys(os.networkInterfaces()).map(function (nic) {
^
Error: ENOSYS, function not implemented
at Object. (/opt/Node/lib/node_modules/npm/node_modules/npmconf/config-defs.js:349:38)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/opt/Node/lib/node_modules/npm/node_modules/npmconf/npmconf.js:4:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)

Help!!

Peter Tribble said...

Ouch. That's a very recent change to npm. I've logged an issue against it.

https://github.com/isaacs/npm/issues/4309

In the meantime, 0.10.22 has a compatibly working version of npm.

Unknown said...

Hi, Peter. Is http://www.petertribble.co.uk/Solaris/TRIBnode-0.10.25.0.pkg.bz2 available for Solaris 10, please?

Appreciate for your reply.

Unknown said...

Hi Peter,
Could you please help to confirm that is http://www.petertribble.co.uk/Solaris/TRIBnode-0.10.25.0.pkg.bz2 available for Solaris(X86)?

Appreciate for your kindly reply.

Peter Tribble said...

Yes, you can download current Node packages for Solaris 10 x86 from http://www.petertribble.co.uk/Solaris/node.html

Anonymous said...

Do you have 64 bit node js?

Peter Tribble said...

I don't publish a 64-bit package for Solaris 10, although it would be easy enough to compile (it's just an extra configure flag).

The 32-bit build should work for most purposes - and will work on both 32 and 64-bit hardware. If you need more than a 3G address space (which is the primary thing that 64-bit would get you) then I'm not sure that Node is necessarily the obvious choice.

Is there a specific problem you're trying to solve for which the 32-bit build isn't suitable?

Unknown said...

Hi Peter,

Is there any version of node available for Solaris 11 Sparc.

Really appreciate any lead.

Unknown said...

Hi Peter,

Is there any version of node available for Solaris 11 Sparc.

Really appreciate any lead.

Peter Tribble said...

Node isn't available for sparc, and I can't see that changing.

The problem isn't Node as such - most of the Node-specific code is portable. The underlying V8 javascript engine simply hasn't been ported to sparc so, unless someone does that work (and it's likely to be quite a bit of work), Node.js will never be available for sparc.

Peter Tribble said...

And as a followup to an earlier comment, just in case someone ends up here, there are now 64-bit builds of some of the most recent versions available at http://www.petertribble.co.uk/Solaris/node.html