Link index.html client.js and server.js

I’m starting with Node.js and I have already a problem in my first program. Below is the code I’m using. Index.html:

<!DOCTYPE html>
    <meta charset="utf-8">
    <title>Random Temperatures</title>
    <input type="text" id="tb" name="tb" />
    <input type="button" value="Random Number!" id="myButton" name="myButton"/>
    <script src="client.js"></script>


const textBox = document.getElementById('tb');
const button = document.getElementById('myButton');
button.addEventListener('click', function(e) {
    var rnd = Math.floor(Math.random() * 100);
    textBox.value = rnd;


var app = require('http').createServer(response);
var fs = require('fs');
console.log("App running…");
function response(req, res) {
    fs.readFile(__dirname + '/public/index.html',
    function (err, data) {
        if (err) {
            return res.end('Failed to load file index.html');

When I start the application I go to the browser the text box and the button appear. But in the browser console I’m getting these errors:

client.js:1 Uncaught SyntaxError: Unexpected token <

ContentScript.js:112 Exception in onResRdy: TypeError: Cannot read
property ‘htmlRes’ of undefined

localhost/:1 Unchecked runtime.lastError: Could not establish
connection. Receiving end does not exist.

I guess my problem is the linking between the 3 files but I tried several things and I can’t solve the problem. I’m sure it’s a stupid error but forgive me I’m just getting start. Any advice?

134 thoughts on “Link index.html client.js and server.js”

  1. Pingback: female viagra
  2. Pingback: herbal cialis
  3. Pingback: cialis europe
  4. Pingback: cialis sex pill
  5. Pingback: free viagra
  6. Pingback: cialis orange pill
  7. Pingback: viagra india 100mg
  8. Pingback: viagracarme
  9. Pingback: cheapest viagra
  10. Pingback: buy ivermectin otc
  11. Pingback: stromectol online
  12. Pingback: tadalafil mylan
  13. Pingback: buy sildenafil
  14. Pingback: viagra alternative
  15. Pingback: herbal viagra
  16. Pingback: viagra prices
  17. Pingback: viagra homme
  18. Pingback: viagra or cialis