Search code examples
javascriptnode.jsexpresspug

My JavaScript file is not being read in my PUG file. Any idea why this not working?


Things I've tried:

I've tested the confetti.js file on a simple HTML website, but when I want to use it for a ExpressJS/Pug project, it's not working.

I've pasted the js code directly as a inline script, and it worked, but not like it does on a regular HTML website.

However, I want to use it in a script file, and it's not working at all. Here is my code:

extends layout

block content
    header
        h1.header-title Cool Title
    main.about-card
        .wrapper-about
            .wrapper-inner-about
                h2.about-title About
                hr
                p.about-body text stuff......
                p.about-body text stuff......
            .btn-div-1
                button#demo.button(onclick="move_login()") Login
                button(class="register-login register-white" onclick="move_register()") Register
    script(src="confetti.js")
    script.
        function move_login() {
            window.location.href = '/user-login';
        }
        function move_register() {
            window.location.href = '/user-register';
        }

I appreciate the help.


Solution

  • The issue was I did not add the JS file to my public folder. Thanks for your help Muhammad Saquib Shaikh.