Javascript button onclick event not triggered

I have a javascript file "functions.js" with the following:

function changeLabel() {

a main javascript file server.js

var http = require('http');
var fs = require('fs');
var port = process.env.PORT || 1337;

fs.readFile('./index.html', function (err, html) {
    if (err) {
        throw err;
    http.createServer(function (request, response) {
        response.writeHeader(200, { "Content-Type": "text/html" });

and a html file with this:

<!DOCTYPE html>

<html xmlns="">

    <meta charset="utf-8" />
    <script type = "text/javascript" src="functions.js"></script>
    <button id="button" onclick="changeLabel()">Click me</button>


and my json is

  "name": "test",
  "version": "0.0.0",
  "description": "test",
  "main": "server.js",
  "author": {
    "name": ""

When looking at the network tab i have this:
enter image description here

But I do not manage to get the alert when clicking the button. I am pretty new to javascript coding…
Do I need to include my functions.js in the json file?

I am using visual studio 2019.

Thanks for your help guys

131 thoughts on “Javascript button onclick event not triggered”