Can't include a JavaScript library


Hi, I am having trouble with including a JavaScript library in an .html file. The file begins like this (note comment!):

<!DOCTYPE html>
	<title>GamePad Library Demo</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<script src=""></script>
	<script src="name.js"></script>

The file name.js is in the same folder as the .html file… am I doing something wrong?

Have been playing around with it for hours, can anybody help me?


Not sure if this will work but try adding a slash (/) before src="name.js". Or create a folder called js and change the src to src="js/name.js".


Thanks for the suggestions! I just tried both, still doesn’t work though…


Try including type="text/javascript" before the src attribute.


Yea, tried that before, and tried again just now… doesn’t do it…

I am working on a sort of offline version of cloud9, (on a BeagleBone Black running Debian, the cloud9 ide comes with it.) Still should work though!

Just pasting the 1000+ line library right into my HTML file wouldn’t be a good idea I think…


Any other suggestions? Maybe some sort of work-around I could try?


use chrome devtools to see what script browser tries to load when you use src=name.js
the above can only work if your html file and name.js are in same folder, and your server doesn’t use some special rules.
otherwise you need to use a relative path instead.


Hi, thanks for the reply! I’ll try to explain in more detail what seems to be happening, I hope it makes sense, I am somewhat new to server programming…

This is my server:

var app = require('http').createServer(handler);
var fs = require('fs');

console.log('Server running on: http://' + getIPAddress() + ':8888');
function handler (req, res) {
  if (req.url == "/favicon.ico"){   // handle requests for favico.ico
  res.writeHead(200, {'Content-Type': 'image/x-icon'} );
  console.log('favicon requested');
  fs.readFile('try2.html',    // load html file
  function (err, data) {
    if (err) {
      return res.end('Error loading index.html');

// Get server IP address on LAN
function getIPAddress() {
  var interfaces = require('os').networkInterfaces();
  for (var devName in interfaces) {
    var iface = interfaces[devName];
    for (var i = 0; i < iface.length; i++) {
      var alias = iface[i];
      if ( === 'IPv4' && alias.address !== '' && !alias.internal)
        return alias.address;
  return '';

try2.html is the page I included an excerpt from in my original post; when I run the server I can access it at You said to use the Chrome devtools to see what script my browser tries to load… If I’m understanding the Chrome devtools correctly, my browser tries to find name.js at, and then somehow “fills” name.js with the contents of try2.html… is this possible???

You suggested using a relative path, how would I do that?
Or could I alter my server to somehow give the page access to name.js???


sorry about the duplicate posts, don’t know how that happened… :frowning:


Well, to get name.js on the browser, you need to send it from server when requested.
see for a simple example of static file server.
In the final application you probably should use one of existing modules from npm (e.g. connect) instead of writing completely custom one


Thanks for the tip… I tried copying parts from the link you sent me… In the end, I went with this server: It seems to work perfectly for my application, so far at least. I have started to look at npm connect, might switch to that at some point… Thanks again, John