Notice: Google is retiring their OpenID 2.0 authentication service. If you are using Google OpenID as your primary means to authenticate on this forum, then please either:


How do I install Node.js with the express framework?

asked 16 Aug '11, 02:51

ryans's gravatar image

ryans ♦♦
accept rate: 42%

edited 29 Apr '13, 18:55

seanf's gravatar image

seanf ♦♦

This can be done in two steps:

  1. Create a new application of type Custom Application (Listening on port)
  2. Install node.js, npm (the node package manager), and the express framework into your account

Step 2 can be performed using the following commands:

mkdir -p $HOME/src
cd $HOME/src
wget ''
tar -xzf node-v0.10.5.tar.gz
cd node-v0.10.5

# All of these scripts use "#!/usr/bin/env python". Let's make that mean python2.7:
mkdir MYPY
ln -s $(which python2.7) $PWD/MYPY/python

./configure --prefix=$HOME
make         # 5.5m
make install

# restore the PATH (we don't need `$PWD/MYPY/python` anymore).
# Then, make sure $HOME/bin is on the PATH
export PATH=$HOME/bin:$PATH
echo 'export PATH="$HOME/bin:$PATH"' >> $HOME/.bashrc
hash -r

# Set the node modules path
export NODE_PATH="$HOME/lib/node_modules:$NODE_PATH"
echo 'export NODE_PATH="$HOME/lib/node_modules:$NODE_PATH"' >> $HOME/.bashrc

# now install express framework
cd $HOME
npm install -g express
npm install -g stylus
npm install -g jade

# create express framework "hello world" project
mkdir -p $HOME/node_projects
cd $HOME/node_projects
express -s -c stylus helloworld
cd helloworld

# use the PORT from your Custom Application created at the beginning!
sed -i "s/app.set('port', process.env.PORT || 3000);/app.set('port', process.env.PORT || $PORT);/" app.js

# run it
cd $HOME/node_projects/helloworld
node app.js

Hope that helps!

permanent link
This answer is marked "community wiki".

answered 16 Aug '11, 02:56

ryans's gravatar image

ryans ♦♦
accept rate: 42%

edited 29 Apr '13, 18:54

seanf's gravatar image

seanf ♦♦

Thanks for this guide, but how do you then view the application? How do you point a domain at the helloworld application?

(01 Sep '11, 06:57) AnnaPS AnnaPS's gravatar image


You need to assign this app to a website. Requests made for this website will then be forwarded to the port assigned to the app.

I hope this clears it up.

(01 Sep '11, 07:00) todork todork's gravatar image

Yep, the problem is that the app is located at $HOME/helloworld: with Webfaction, doesn't it need to be at $HOME/webapps/helloworld in order to be spotted as an app?

(01 Sep '11, 07:18) AnnaPS AnnaPS's gravatar image

No, that's not the case here. When you assign a "Custom Application (Listening on port)" app to a site, it's just used as a placeholder so nginx (the frontend web server) can forward the requests for this site to the correct port. To map the app to this site, you just need to make sure that it's configured to run on the correct port.

(01 Sep '11, 10:27) todork todork's gravatar image

require.paths.push has been deprecated. Add this to your ~/.bash_profile instead:

export NODE_PATH=$HOME/lib/node_modules:$NODE_PATH

(03 Apr '12, 20:57) keenans keenans's gravatar image

It's been almost a year since this was first posted - are there any plans to add a node installer?

btw - these instructions are not working for me with node version 0.8.4.

(02 Aug '12, 09:01) Tex Tex's gravatar image

No, we still have no plans to add a Node installer - there's an updated guide written by one of our users here: Real-World node.js (using Webfaction) - Part 1

(02 Aug '12, 13:37) seanf ♦♦ seanf's gravatar image

The source for npm has been updated to

Great guide!

(03 Sep '12, 05:22) Aventus Aventus's gravatar image

Thanks, I've edited the original answer to reflect the new install URL.

(03 Sep '12, 05:33) todork todork's gravatar image

Also worth noting that as of the 0.6 branch, npm is bundled with node so no need to install it separately

(04 Sep '12, 15:44) Dave Stevens Dave%20Stevens's gravatar image

I've now updated this guide from node 0.4.12 to 0.8.9, and the above issues should be fixed. Hope that helps!

(23 Sep '12, 22:03) ryans ♦♦ ryans's gravatar image

I'm Happy! Thanks :)

(17 Oct '12, 19:24) marcoslhc marcoslhc's gravatar image

Thanks for this guide. It worked perfectly. Initially, I tried other methods to get around the python problem, but this did the trick. Thanks again!

(01 Nov '12, 21:04) wchest wchest's gravatar image

Hai, Am getting this error while giving the command npm install -g express

root@otc-desktop:~# npm install -g express npm http GET npm http GET npm http GET npm ERR! Error: tunneling socket could not be established, cause=socket hang up npm ERR! at ClientRequest.onError (/root/lib/node_modules/npm/node_modules/request/tunnel.js:161:17) npm ERR! at ClientRequest.g (events.js:185:14) npm ERR! at ClientRequest.EventEmitter.emit (events.js:88:17) npm ERR! at CleartextStream.socketErrorListener (http.js:1330:9) npm ERR! at CleartextStream.EventEmitter.emit (events.js:88:17) npm ERR! at SecurePair.exports.connect.cleartext._controlReleased (tls.js:1267:15) npm ERR! at SecurePair.EventEmitter.emit (events.js:88:17) npm ERR! at SecurePair.error (tls.js:921:10) npm ERR! at EncryptedStream.CryptoStream._done (tls.js:395:17) npm ERR! at EncryptedStream.CryptoStream._pull (tls.js:546:12) npm ERR! If you need help, you may report this log at: npm ERR! npm ERR! or email it to: npm ERR!

npm ERR! System Linux 2.6.32-41-generic npm ERR! command "/root/bin/node" "/root/bin/npm" "install" "express" npm ERR! cwd /root npm ERR! node -v v0.8.9 npm ERR! npm -v 1.1.61 npm ERR! code ECONNRESET npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /root/npm-debug.log npm ERR! not ok code 0

Pls tell me anybody how to solve this issue...

thanks, vidhya

(04 Dec '12, 04:41) sree sree's gravatar image

This looks like a local issue, rather than in a WebFaction environment. Since we are not aware of your local setup, our support is limited.

Judging from the error shown this looks like a network issue but I'd suggest you take a look at your /root/npm-debug.log file for more info and maybe try to the contact node's community on this issue instead.

(04 Dec '12, 05:56) iliasr ♦♦ iliasr's gravatar image

i just cant handle this. i tried everything. Node works good, npm works good. I can install express but when i use the command "express" always appears "command not found". I am desperate everything works except this "express module". I am using Mountain Lion OSX. I hope somebody can help

(12 Jan '13, 11:18) meitoli meitoli's gravatar image
showing 5 of 16 show 11 more comments

Worked perfectly with node 0.8.18 -- thanks!

permanent link

answered 28 Jan '13, 17:04

dowdrake's gravatar image

accept rate: 0%

Thanks. This was great information. Worked very well for me.

One simplification.

Instead of the convoluted tricks with MYPY, you can simply do the following:

cd node-v0.8.18/
python2.7 configure --prefix=$HOME
make PYTHON=python2.7
make PYTHON=python2.7 install

This worked perfectly for me, without having to muck around with the PATH.

permanent link

answered 30 Jan '13, 05:04

Navin%20Kabra's gravatar image

Navin Kabra
accept rate: 0%

edited 30 Jan '13, 05:21

Remember to place logs in /home/username/logs/user/ so they can be rotated. Also, to launch node at reboot, use @reboot in crontab.

I use forever to keep node running, and launch it on reboot (via forever) through crontab.

permanent link

answered 01 Apr '13, 09:00

Madsn's gravatar image

accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 16 Aug '11, 02:51

question was seen: 29,762 times

last updated: 29 Apr '13, 18:55

Features & prices    Sign up    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
© Copyright 2003-2015 Swarma Limited - WebFaction is a service of Swarma Limited