Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why Node.js cannot run my JavaScript code in the terminal?

enter image description here

Can anyone please tell me why my javascript code cannot be executed? What is Uncaught SyntaxError: Unexpected Identifier?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You have a > before your text cursor. This means that you’re already in Node.

Right now, what’s happening is you’re telling Node to run the following JavaScript:

node index.js

which, of course, is not valid JavaScript.

You need to exit Node so that the standard terminal is displayed, such as cmd or powershell (press Control-C a couple times)

enter image description here

Then you can type in node index.js. If you’re in the same directory as the index.js file, it’ll execute.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading