My Sample Project

How to include nodejs modules in html files?

First of all I am new to nodejs and secondly below is my question. How to include nodejs net module in js which is loaded in html?? My js file looks like this.

net = require('net'); var client = net.createConnection(8000, '192.168.15.59'); client.on('connect',function()< console.log('Connected To Server'); >); client.on('data',function(data)< console.log('Incoming data:; ' + data); >); 
   

require js defining modules in html script tags

I am trying to define a module for the initual configuration options of my app inside an script tag in my html. but I get the following error:

Error: Module name "options" has not been loaded yet for context: _. Use require([]) http://requirejs.org/docs/errors.html#notloaded 
  

Источник

How to get started with RequireJS

This setup assumes you keep all your JavaScript files in a "scripts" directory in your project. For example, if you have a project that has a project.html page, with some scripts, the directory layout might look like so:

Add require.js to the scripts directory, so it looks like so:

Оцените статью