Node.js provides multiple ways for the propagating and handling errors occur during the Node.js application execution. The error reported by a Node.js application depends on the type of error. There are generally four types of errors in the Node.js application. Standard JavaScript errors – Like EvalError SyntaxError RangeError ReferenceError TypeError URIError System Error – For example attempt to open a file that does not exist, attempting to send data over a closed socket, etc; User-specified Errors – These errors triggered by application code. Also can be known as human mistakes…
Read MoreTag: node
Node.js – Hello World Example
You can run Node.js application an console based or web-based application. Console based application will run your system terminal and a web-based application will use an inbuilt web server to make an application accessible on the web browser. Console-based Hello World Example Use the Node.js console module to print output on your system console. Create a JavaScript file nodejs_hello_console.js using the below content.
1 | console.log('Hello World'); |
Execute your script using the node node nodejs_hello_console.js [output] Hello World! Web-based Hello World Example A Node.js web application is build with 3 parts. Import module…
Read MoreNode.js – REPL
REPL stands for Read, Eval, Print, and Loop. Node.js also provides a REPL environment for quicky testing and debugging Node.js code. You can also store all the commands executed on Node REPL by setting the NODE_REPL_HISTORY environment variable. Node.js REPL will store all commands to the file set with this variable export NODE_REPL_HISTORY=/var/log/node-repl.log Use CTRL + C + C to exit from REPL console. Start REPL Console Run command node on your system console and this will provide you REPL prompt (>) for Node.js. Where you can run and test…
Read MoreNode.js Basics
Node.js Tutorials
Read More