I want to test small snippets of JavaScript code in VSCode's terminal before inserting them in my project. I want something similar to Chrome's Devtools console.
Asked
Active
Viewed 1.3k times
1
-
Just create a test file and and execute the test file. – Get Off My Lawn Feb 25 '20 at 23:05
-
1@HereticMonkey that thread dismissed a quite valid solution to use node, which requires zero plugins installed for VSC. – crtag Feb 25 '20 at 23:08
-
@crtag "dismissed"? There is no dismissal in Stack Overflow. Add an answer to that question that suggests using NodeJS or upvote the one that obliquely does already. – Heretic Monkey Feb 25 '20 at 23:10
-
@HereticMonkey for some reason I was thinking this was for node... – Get Off My Lawn Feb 25 '20 at 23:12
-
@GetOffMyLawn A lot of chatter about using node as a solution in the answers and comments, I can see why :). – Heretic Monkey Feb 25 '20 at 23:14
-
@HereticMonkey Yes that is the same question, but it does not contain the word "terminal" anywhere, maybe that is why I could not find it via googling. – Strategy Thinker Feb 27 '20 at 18:06
3 Answers
6
Install node and npm from https://nodejs.org/en/download/
After installation in VSCode under terminal tab run
node
Paste your snippet to run your javascript code or use node filepath/filename.js
to see result.

Hunter
- 129
- 5
4
Just run the command node
to enter a node environment where you can run arbitrary JavaScript.

Ian
- 5,704
- 6
- 40
- 72