Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js and Express on Windows

Tonight I decided I'd try to build a simple Node.js application using Express on my Windows 7 machine. The installation went fairly smoothly, but Express refuses to cooperate. Here are the steps I've taken:

  1. Installed Node.js using the MSI available at http://nodejs.org/dist/v0.6.9/node-v0.6.9.msi
  2. Installed Express by running npm install express g from a command prompt.
  3. Created a directory for the application c:\source\node> mkdir newapp.
  4. Changed directory to the application directory c:\source\node> cd newapp.
  5. Ran Express: c:\source\node\newapp> express --sessions --css stylus.

At this point the node.exe process fires up and runs endlessly at 25% CPU Time and continually uses more memory. After running for 20+ minutes the node.exe process uses 300+ MB of Memory. The express command never completes and the newapp directory remains unaltered.

If I run express --help I see the help output in the console. I've tried running the command prompt as and Administrator but still Express appears to hang.

Does anyone have a clue what's going on or what I'm doing wrong? Thanks in advance!

like image 414
Phil Klein Avatar asked Feb 01 '12 05:02

Phil Klein


Video Answer


1 Answers

This is a bug in the Windows version of Node v0.6.9. Filesystem access is pretty much messed up. Rollback to v0.6.8 http://nodejs.org/dist/v0.6.8/node-v0.6.8.msi and you should be fine.

The Express.js command line on Windows doesn't quite work well either. I just tried with Node v0.6.8.

This works

express --sessions myapp

This doesn't work for me

express --sessions --css stylus myapp

Fortunately you can add stylus support manually in your generated app. Open up app.js and in the app.configure function, add:

app.use(require('stylus').middleware({src: __dirname + '/public'}));

Hope this helps!

Update:

Oh ya, don't forget your NPM commands. In your app directory, you may need to npm install jade and npm install stylus.

like image 122
JP Richardson Avatar answered Sep 28 '22 19:09

JP Richardson