简体   繁体   中英

How to start a script/app in node.js?

If I type console.log('Hello World'); in node.js it works, I get the "Hello World" message back.

But if I make a "helloworld.js" document with console.log('Hello World'); inside and then type "node helloworld.js" in node then nothing happens.

I have tried placing the script in same folder as node.js but still doesn't work.

Make sure that you're not running Nodejs.exe because that is the REPL .

Instead you should open a regular Command Prompt window ( cmd.exe ) and run the command

node helloworld.js

Make sure you run this command in the directory where the js file exists, the node application path is mapped in your environment settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM