Note that there are some explanatory texts on larger screens.

plurals
  1. POCoffeScript: require not recognized when runninjg from the browser
    primarykey
    data
    text
    <p>I am trying to run this piece of code taken from <a href="http://coffeescriptcookbook.com" rel="noreferrer">http://coffeescriptcookbook.com</a> embedding it into an html. </p> <pre><code>net = require 'net' domain = 'localhost' port = 9001 connecting = (socket) -&gt; console.log "Connecting to real-time server" connection = net.createConnection port, domain connection.on 'connect', () -&gt; console.log "Opened connection to #{domain}:#{port}" connecting connection connection.on 'data', (data) -&gt; console.log "Received: #{data}" connection.on 'end', (data) -&gt; console.log "Connection closed" </code></pre> <p>This code is in file named client.coffe and when i run it with the coffee command: coffee client.coffe it runs fine and connects to the server, but when I embbed it in a html file and open it i get this error: Uncaught ReferenceError: require is not defined.</p> <p>My html script tags looks like this:</p> <pre><code> &lt;script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js" type="text/javascript" charset="utf-8" &gt;&lt;/script&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt; &lt;script src="{% get_static_prefix %}functions.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt; &lt;script src="{% get_static_prefix %}jquery.dajax.core.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt; &lt;script src="{% get_static_prefix %}client.coffee" type="text/coffeescript" charset="utf-8"&gt;&lt;/script&gt; </code></pre> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload