Installing node.js and stuff

I thought to install SocketStream and experiment with it. But as is the way with all system things, there are a million substeps that must be completed first.

I needed npm to install SocketStream, and needed node.js to install npm, and needed homebrew to install node.js.

Installing homebrew (actually reinstalling since it was messed up by my upgrade to Yosemite):

 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 225651, done.
remote: Compressing objects: 100% (59321/59321), done.
remote: Total 225651 (delta 165105), reused 225621 (delta 165082)
Receiving objects: 100% (225651/225651), 51.46 MiB | 115.00 KiB/s, done.
Resolving deltas: 100% (165105/165105), done.
From https://github.com/Homebrew/homebrew
* [new branch] master -> origin/master
Checking out files: 100% (3430/3430), done.
HEAD is now at 3d186e9 nss: update 3.17.3 bottle.
==> Installation successful!
==> Next steps
Run `brew doctor` before you install anything
Run `brew help` to get started

After that, I resolved some problems reported by brew doctor.

Now installing node.js:

wmodes$ brew install node
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/node-0.10.3
######################################################################## 100.0%
==> Pouring node-0.10.35_2.yosemite.bottle.1.tar.gz
==> Caveats
If you update npm itself, do NOT use the npm update command.
The upstream-recommended way to update npm is:
npm install -g npm@latest
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
/usr/local/Cellar/node/0.10.35_2: 2146 files, 22M

And now we make a node test server:

wmodes$ vi server.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');

And then we try running it:

 wmodes$ node server.js
Server running at http://127.0.0.1:8124/


And lo and behold, in the browser:

Screen Shot 2015-01-16 at 12.32.23 PM

Woot.

And then since the other thing true of systems work is that do-overs are the rule, not the exception, I got this far to find that there is a reported bug installing node with homebrew. And the suggested remedy is to install node.js from the regular mac package installer.

So I do. And server.js still works. Carry on.

So now we can try installing SocketStream.

wmodes$ npm install -g socketstream
> fsevents@0.3.0 install /usr/local/lib/node_modules/socketstream/node_modules/chokidar/node_modules/fsevents
> node-gyp rebuild
CXX(target) Release/obj.target/fse/fsevents.o
In file included from ../fsevents.cc:86:
../src/constants.cc:10:66: warning: template argument uses unnamed type
[-Wunnamed-type-template-args]
object->Set(NanNew("kFSEventStreamEventFlagNone"), NanNew ws@0.4.30 install /usr/local/lib/node_modules/socketstream/node_modules/engine.io/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node
SOLINK_MODULE(target) Release/bufferutil.node: Finished
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node
SOLINK_MODULE(target) Release/validation.node: Finished
/usr/local/bin/socketstream -> /usr/local/lib/node_modules/socketstream/bin/socketstream
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/npm-package-arg requires semver@'4' but will load
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/semver,
npm WARN unmet dependency which is version 2.3.0
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/read-installed/node_modules/readdir-scoped-modules requires graceful-fs@'^3.0.4' but will load
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/graceful-fs,
npm WARN unmet dependency which is version 3.0.2
socketstream@0.3.11 /usr/local/lib/node_modules/socketstream
 +---- uid2@0.0.3
 +---- apitree@1.2.0
 +---- commander@2.3.0
 +---- eventemitter2@0.4.14
 +---- redis@0.12.1
 +---- colors@1.0.3
 +---- semver@4.0.3
 +---- uglify-js@1.3.3
 +---- connect-redis@1.4.4 (redis@0.8.1, debug@2.1.1)
 +---- clean-css@0.4.2 (optimist@0.3.7)
 +---- connect@2.26.5 (cookie@0.1.2, fresh@0.2.4, pause@0.0.1, cookie-signature@1.0.5, response-time@2.0.1, vhost@3.0.0, basic-auth-connect@1.0.0, on-headers@1.0.0, media-typer@0.3.0, bytes@1.0.0, parseurl@1.3.0, cookie-parser@1.3.3, depd@0.4.5, connect-timeout@1.3.0, qs@2.2.4, debug@2.0.0, finalhandler@0.2.0, method-override@2.2.0, serve-favicon@2.1.7, morgan@1.3.2, type-is@1.5.5, serve-static@1.6.4, body-parser@1.8.4, errorhandler@1.2.4, serve-index@1.2.1, csurf@1.6.5, multiparty@3.3.2, express-session@1.8.2, compression@1.1.2)
 +---- chokidar@0.9.0 (recursive-readdir@0.0.2, fsevents@0.3.0)
 +---- engine.io@0.7.9 (base64id@0.1.0, engine.io-parser@0.3.0, debug@0.6.0, ws@0.4.30)

Okay, some warnings but it seemed to work.

Now we create a basic app example setup:

wmodes$ socketstream -s -j new my_app
Success! Created app 'my_app' with:
/ Basic chat demo (-m for minimal install)
/ Javascript example code (-c if you prefer CoffeeScript)
/ Jade for views
/ Stylus for CSS
Next, run the following commands:
cd my_app
[sudo] npm install
To start your app:
node app.js

Now we install the app with node:

wmodes$ cd my_app/
wmodes$ npm install
> fsevents@0.3.0 install /Users/wmodes/my_app/node_modules/socketstream/node_modules/chokidar/node_modules/fsevents
> node-gyp rebuild
CXX(target) Release/obj.target/fse/fsevents.o
In file included from ../fsevents.cc:86:
../src/constants.cc:10:66: warning: template argument uses unnamed type
[-Wunnamed-type-template-args]
object->Set(NanNew("kFSEventStreamEventFlagNone"), NanNew ws@0.4.30 install /Users/wmodes/my_app/node_modules/socketstream/node_modules/engine.io/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node
SOLINK_MODULE(target) Release/bufferutil.node: Finished
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node
SOLINK_MODULE(target) Release/validation.node: Finished
ss-jade@0.1.3 node_modules/ss-jade
 +---- jade@0.27.7 (commander@0.6.1, mkdirp@0.3.5, coffee-script@1.4.0)
ss-hogan@0.1.3 node_modules/ss-hogan
 +---- hogan.js@2.0.0
ss-stylus@0.1.9 node_modules/ss-stylus
 +---- nib@1.0.4 (stylus@0.45.1)
+---- stylus@0.49.2 (css-parse@1.7.0, mkdirp@0.3.5, debug@2.1.1, sax@0.5.8, source-map@0.1.43, glob@3.2.11)
socketstream@0.3.11 node_modules/socketstream
 +---- uid2@0.0.3
 +---- apitree@1.2.0
 +---- commander@2.3.0
 +---- eventemitter2@0.4.14
 +---- redis@0.12.1
 +---- colors@1.0.3
 +---- semver@4.0.3
 +---- uglify-js@1.3.3
 +---- connect-redis@1.4.4 (debug@2.1.1, redis@0.8.1)
 +---- clean-css@0.4.2 (optimist@0.3.7)
 +---- connect@2.26.5 (cookie@0.1.2, fresh@0.2.4, pause@0.0.1, cookie-signature@1.0.5, response-time@2.0.1, vhost@3.0.0, basic-auth-connect@1.0.0, on-headers@1.0.0, bytes@1.0.0, media-typer@0.3.0, parseurl@1.3.0, cookie-parser@1.3.3, depd@0.4.5, connect-timeout@1.3.0, qs@2.2.4, debug@2.0.0, finalhandler@0.2.0, method-override@2.2.0, serve-favicon@2.1.7, morgan@1.3.2, body-parser@1.8.4, type-is@1.5.5, multiparty@3.3.2, serve-static@1.6.4, serve-index@1.2.1, csurf@1.6.5, compression@1.1.2, errorhandler@1.2.4, express-session@1.8.2)
 +---- chokidar@0.9.0 (recursive-readdir@0.0.2, fsevents@0.3.0)
 +---- engine.io@0.7.9 (base64id@0.1.0, engine.io-parser@0.3.0, debug@0.6.0, ws@0.4.30)

And now we start it:

wmodes$ npm start
> my_app@0.0.1 start /Users/wmodes/my_app
> node app.js
Starting SocketStream 0.3.11 in development mode...

This time it's not going to helpfully tell me what port to connect on. Uh, no that would be too easy. Ah, found it.

Screen Shot 2015-01-16 at 1.15.06 PM

Oh hai single-page app, daaaaaanm.

Leave a Reply