Ask coding questions

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

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 (85) [earned 5 cycles]
View Answer
Commentshotnewtop
1
ryanhcode (85)

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!

1
vedprad1 (470)

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