– require is not defined, io is not defined errors

Lately I have been woking on, trying to learn what it is all about and how to use it.

This is what I did on my local machine trying to get a simple app to work:

-Installed node.js from (on 64-bit win8)
-Installed module on node.js using npm (node package manager) (
-Quickly created a sample application using node
-Started node server
-Opened my index.html file

BAM! I got these 2 errors on chrome javascript console:
require is not defined
io is not defined

I was following some examples and everything seemed right to me but there was one thing that I had done different from the samples I had inspected on the net. These samples showed the reference to as below:

<script src="http://localhost:<port number>/"></script>

But when I checked the installation I saw no “” folder with “” file in it, so I thought they were using older versions of and/or node.js in the samples, and I decided to change the “” reference as below:

<script src="node_modules/" type="text/javascript"></script>

Because that was where file was. Apparently I was wrong!

You have to explicitly state host, port and directory, because file is served from the node server that way.

Hope this helps someone.

Good luck,

Leave a Reply

Your email address will not be published. Required fields are marked *