Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

how to run nodejs flatiron/director example

how to run nodejs flatiron/director example

Problem

I tried to run the https://github.com/flatiron/director#client-side example to get familiar with director.js.

I am not able to setup the flatiron module on the client-side.

In my html page (say, /page.html) I replaced the location of director.js with a location of its counterpart from my project:

/node_modules/flatiron/node_modules/director/lib/director.js

Upon loading the /page.html page in the browser I got errors: export and Router not defined.

First idea: After all, on the browser side there is no Nodejs...

Ok, I thought that browserify could help me with it. I generated a single 'browser-side' bundle (was it necessary?):

my_project> node node_modules/browserify/bin/cli.js node_modules/flatiron/node_modules/director/lib director.js -o cs_director.js

and I used it in the line:

The problem is that the error

Uncaught ReferenceError: Router is not defined
(anonymous function)

still appears so I guess the whole example will not work.

I am new to node/js and I am not sure if it makes sens what I have done in my case described above... Does anybody how to solve it?

Or generally, how to use 'isomorphic' stuff on a browser-side? The html examples on Github just refer to the same .js files as server-side examples ...

Can you recommend any tutorials, examples?

Thanks, -gvlax

Problem courtesy of: gvlax

Solution

You can find a browser-specific build of director here which has all of the server code stripped away.

Solution courtesy of: fent

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

how to run nodejs flatiron/director example

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×