VS Code - HTML-JS link issue (Node.js ??)
Hi there,
Just wanted to see if anyone else ran into these issues while using VS Code:
I'm trying to use VS Code as much as I can (which I linked to github) so I also build on my github activity.
I'm currently working on the Counter App.
After the first attempts (I'm using the Live Server Extension), it seemed it simply won't work.
I then copied the code from VS Code and Pasted it into Code Pen... it still didn't work... I then literally wrote the whole code from scratch.. line by line into a new Code Pen and it worked (not finished, still WIP).
I eventually noticed that the VS Code terminal was giving me an error, apparently I didn't have the Node.js installed. I installed it, but now I still get these errors (also visible in the attached ss).
[Running] node "g:\Developer Pro\Counter_App\counter.js"
g:\My Drive\D'ale Mele\Programming\MY_SPACE\COLT\Developer Pro\Counter_App\counter.js:1
const buttonMinus = document.getElementById("button-minus");
^
ReferenceError: document is not defined
at Object.<anonymous> (g:\Developer Pro\Counter_App\counter.js:1:21)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49
Node.js v20.10.0
[Done] exited with code=1 in 0.124 seconds
As I understand it from here:
Node.js is a server environment, not a browser environment (like Code Pen, I reckon).
So, in the end, my question is: is there any way I can make VS Code work, and I mean make the JS work.
PS: I assume I did all the technical things I was supposed to do, including linking the JS to my HTML. I tried it with both:
<script src="counter.js"></script>
&
<link rel="stylesheet" href="counter.js">
Idk, I might have missed something. Any tip will be much appreciated!
1
6 comments
Florin Ghimici
5
VS Code - HTML-JS link issue (Node.js ??)
Developer Pro
skool.com/developerpro
Learn how to code. Make money. Have fun. Enjoy life.
Leaderboard (30-day)
Powered by