2

I'm trying to build a simple bidirectional DNode app using the DNode tutorial here. However I'm not sure how to serve the client-side dnode js.

The example includes the following code:

var js = require('dnode/web').source();

var httpServer = http.createServer(function (req,res) {
    if (req.url == '/dnode.js') {
        res.writeHead(200, { 'Content-Type' : 'text/javascript' });
        res.end(js);
    }
//...

But the app won't run. I get: "Error: Cannot find module 'dnode/web'"

DNode is installed via npm. Any ideas?

ty.
  • 10,924
  • 9
  • 52
  • 71

2 Answers2

2

dnode/web is the really ancient way of hosting the source. Now /dnode.js is available by default so you can just <script src="/dnode.js"></script>.

substack
  • 3,346
  • 24
  • 14
1

Ran into the same thing, that article appears to be out of date. Go to dnode's page on Github and try the examples there instead. They work.

Steve Kehlet
  • 6,156
  • 5
  • 39
  • 40