visionmedia/express — Issue #1019: Problems setting server
Author: pabloat81
Created: 2012-02-20 02:27:15+00:00
State: open

I am learning node.

i made this simple js file:

(function (port, rootPath, callback) {
express = require('express');
var server;
if (process.argv[2]) port = process.argv[2]; else port = 3333;
if (process.argv[3]) rootpath = process.argv[3]; else rootPath = '.';

if (callback == null) callback = (function () { });
server = express.createServer();
server.configure(function () {
server.use(express.static(rootPath));
server.set('views', rootPath);
return server.set('view options', {
layout: false
});
});
server.get('/', function (req, res) {
return res.render('index.html');
});
server.listen(parseInt(port, 10));
server.on('listening', callback);
}).call(this);

-----
i excecute it like this:
> node -p ./expressServer.js 4000 D:\\Proyectos\\MobileNet\\build\\WWW

----
and i am getting this error:

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: static() root path required
at Object.static (D:\Proyectos\MobileNet\TestMobileBuilder\bin\Debug\node_modules\express\node_modules\connect\lib\m
iddleware\static.js:54:20)
at HTTPServer. (D:\Proyectos\MobileNet\TestMobileBuilder\bin\Debug\expressServer.js:24:28)
at HTTPServer.configure (D:\Proyectos\MobileNet\TestMobileBuilder\bin\Debug\node_modules\express\lib\http.js:542:61)

at Object. (D:\Proyectos\MobileNet\TestMobileBuilder\bin\Debug\expressServer.js:23:12)
at Object. (D:\Proyectos\MobileNet\TestMobileBuilder\bin\Debug\expressServer.js:38:4)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)

Any ideas? I copied the server creation from Brunch.io proyect and it was running ok on Windows.

----
if i try this:
> cd build
> cd WWW
> node -p ../../expressServer.js 4000

Server runs ok, but i need the first one option.

----
Another thing i am getting is:
GET http://localhost:4000/assets/app.js 403 (Forbidden)
in chrome, i need to add some perms to files?

Thanks.