Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

225
Views
Cannot connect javascript to pug file in node express app

I am trying to connect a pug file to a javascript file using script. However I do not see anything viewed in the console in-spite of the console.log that I have placed there.

The following is the structure of my app.js file.

const app = express();

app.set("views", path.join(__dirname, "views"));
app.set("view engine", "pug");

app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, "public")));

I have placed the pug file under the views directory and js file in the public/js folder.

I am able to render and view the pug file on load but it does not seem to be connected to the js file.

The following is the script tag I have added on my pug file.

.script(type='text/javascript', src='js/game-client.js')

This is the folder structure of my app with public and views being in the root directory

public/js/game-client.js
views/gameroom.pug

Please help me on how to proceed this. Any help is appreciated. Thank you!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!