Ask coding questions

← Back to all posts
HTML File trying to use JavaScript in Node.js
vedprad1 (916)

HTML File trying to use JavaScript in Node.js

I am using express and body-parser to parse an HTML file in Node.js. The problem is that whenever I run the file, the HTML shows up here, but the JavaScript code in the <script></script> tag is not running. Does anyone know why this is happening?

My repl can be found here.

Answered by ryanhcode (89) [earned 5 cycles]
View Answer
ryanhcode (89)

It seems to be working fine for me! Remember that the console that the JavaScript is using is not the server console. It is the local console that appears on chrome when you press Ctrl+Shift+I. Try out using alert instead of console.log.

Please upvote if this helped or mark it as the correct answer!

vedprad1 (916)

@ryanhcode : You are right! For some reason, it was not working before. Anyways, Thanks!