Hello Node APP

Lets build our first Hello Node app. To build a simple Hello Node app, you only need a text editor and Node REPL. Just follow these easy steps.

  1. Create a new folder nodeapp in your system
  2. Open any Text Editor.
  3. Create a new file.
  4. Type console.log("hello node");
  5. Save the new file as test.js in nodeapp folder.
  6. Open Terminal
  7. Change directory to nodeapp
  8. Type node test.js

For example, lets say our nodeapp folder is in our desktop and test.js file is there, open terminal and start typing these steps one by one.

cd Desktop/nodeapp

hello node

node test.js

Node JS IDE

There are so many IDE (Integrated Development Environment) available for Node JS. Any developer can choose IDE based on his/her personal preference.

Here is a list of Top IDEs for Node JS Development.

Top IDEs for NodeJS
IDE Name OS Type
VS Code Windows / Mac / Linux Open Source
WebStorm Windows / Mac / Linux Paid
VIM Windows / Mac / Linux Open Source
Eclipse Windows / Mac / Linux Open Source

VS Code

VS Code is one of the most preferred IDE for Node JS. It is open source and available for all platforms. VS Code was developed by Microsoft. There are penalty of reason to choose VS Code for Node JS Development.

Reason to choose VS Code for Node JS

  1. Open Source
  2. Available for windows / Mac and Linux.
  3. Light weight.
  4. Build in IntelliSense for Node JS.
  5. Extensions available.
  6. Debugging
  7. Build-in GIT.
  8. Build-in Console

VS Code is made by Electron, a framework used to deploy Node JS Application for desktop. Electron use HTML and CSS for layout and Node JS for functionality.

Run Node in VS Code

Lets run our last application , i.e. nodeapp saved on desktop on VS Code. Open VS Code and follow these easy steps.

  1. Open VS Code
  2. Press Ctrl + O or Cmd + O in Mac.
  3. Choose folder nodeapp from desktop.
  4. Open Terminal from View or type ^`/control + ` in mac or Ctrl + ` in windows/linux.
  5. Type node testapp.js in VS Code terminal
hello node
node testapp.js

VS Code Terminal can both run the code and debugs.



jsconfig.json

The jsconfig.json file is used to configure the JavaScript language service for a project. It helps VSCode to provide better IntelliSense and code navigation. For VSCode, .js files are treated as part of a JavaScript project, not Node.js.

To create a jsconfig.json file, simply add it to the root of your project and configure it according to your needs.


{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "checkJs": false,
  },
  "exclude": ["node_modules"]
} 

Install @types/node

The @types/node package provides TypeScript type definitions for Node.js. To install it, run the following command in your project directory:

@types/node also provides type definitions for various Node.js modules, making it easier to use them in your TypeScript code. For example, you can use it to get type safety when working with the fs module.

npm install --save-dev @types/node