javascript - how to use node.js module system on the clientside -


i use commonjs module system in clientside javascript application. chose nodejs implementation can't find tutorial or docs on how use nodejs clientside, ie without using node application.js

i included node.js in html page:

<script type="text/javascript" src="node.js"></script> 

note didn't make nodejs on local machine, i'm on windows anyway (i'm aware of cygwin option). when want use require function in own javascript says it's undefined.

var logger = require('./logger'); 

my question is, possible use nodejs this?

node.js serverside application run javascript on server. want use require function on client.

your best bet write require method or use of other implementations use different syntax requirejs.

having done bit of research seems no-one has written require module using commonjs syntax client. end writing own in near future, recommend same.

[edit]

one important side effect require function synchronous , loading large blocks of javascript block browser completely. unwanted side-effect. need know you're doing if you're going this. requirejs syntax set can done asynchronously.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -