Node.js
Developing with Node.js on Windows. Get started developing with Node.js on Windows. See resources to set up your development enviornment, web frameworks, data bases and containers. These Node.js support aliases may be used, although simply resolve to the latest matching version: active, ltsactive, ltslatest, lts, current, supported The last version form is for specifying other releases available using the name of the remote download folder optionally followed by the complete or incomplete version.
Node.js is a lightweight runtime environment for executing JavaScript outside the browser, for example on the server or in the command line. IntelliJ IDEA integrates with Node.js providing assistance in configuring, editing, running, debugging, testing, profiling, and maintaining your applications.
If you need Node.js only as a local runtime for your application or for managing npm packages, running JavaScript linters, build tools, test frameworks, and so on, just install Node.js. If you follow the standard installation procedure, in most cases IntelliJ IDEA detects Node.js itself.
And even if you have no Node.js on your computer, you can install it when creating a new Node.js application in the Create New Project dialog, see Creating a new Node.js application below.
If you want to switch among several Node.js installations, they must be configured as local Node.js interpreters. In most cases, IntelliJ IDEA detects Node.js installations, configures them as interpreters automatically, and adds them to the list where you can select the relevant one.
To run a Node.js application remotely, configure it as a remote interpreter. See Node.js with Docker for details.
Switching between Node.js versions
With IntelliJ IDEA, you can have several installations of Node.js and switch between them while working on the same project.
In the Settings/Preferences dialog Ctrl+Alt+S, go to Languages and Frameworks | Node.js and NPM.
On the Node.js and NPM page that opens, select the required Node.js installation from the Node Interpreter list.
If you followed the standard installation procedure, in most cases the required Node.js installation is on the list. If the installation is missing, click and configure it as a local interpreter manually.
Using a system Node.js version
With IntelliJ IDEA, you can set the default system node alias as your project’s Node.js version. After that this version will be automatically used by all the tools that require Node.js and in all new run/debug configurations. In particular, this means that you will not have to update the settings for each tool if you install a new Node.js version and make it the default node alias in your system.
This functionality is especially helpful when you are using nvm.
In the Settings/Preferences dialog Ctrl+Alt+S, go to Languages and Frameworks | Node.js and NPM.
From the Node interpreter list, select node.
Specify this new Node.js interpreter where applicable, for example in your run/debug configurations or settings of specific tools.
Configuring a local Node.js interpreter
You may need to configure Node.js installation as an interpreter manually, for example, if Node.js is installed in a non-default location so IntelliJ IDEA does not detect it automatically.
In the Settings/Preferences dialog Ctrl+Alt+S, go to Languages and Frameworks | Node.js and NPM.
On the Node.js and NPM page, that opens, click next to the Node Interpreter list.
In the Node.js Interpreters dialog that opens with a list of all the currently configured interpreters, click on the toolbar. In the dialog that opens, choose Add Local from the context menu and choose the installation of Node.js, then click OK. You return to the Node.js Interpreters dialog where the Node interpreter read-only field shows the path to the new interpreter.
In the Package manager field, choose the package manager (npm, Yarn, or pnpm) for the current project.
See Configuring a package manager for a project for details.
When you click OK, you return to the Node.js and NPM page where the Node interpreter field shows the new interpreter.
Using Node.js on Windows Subsystem for Linux
IntelliJ IDEA lets you run and debug Node.js applications using Node.js on Windows Subsystem for Linux. You can choose Node.js on WSL as the default interpreter for the current project or you can configure and use this node version in a Node.js Run/Debug configuration.
Configure Node.js on WSL as the default project node interpreter
In the Settings/Preferences dialog Ctrl+Alt+S, go to Languages and Frameworks | Node.js and NPM.
Click next to the Node Interpreter field, in the Node.js Interpreters dialog that opens, click , and then select Add WSL from the list.
In the Add WSL Node Interpreter dialog that opens, select the Linux distribution you’re using and specify the path to Node.js.
Creating a Node.js application
If you have no application yet, you can generate a IntelliJ IDEA project with Node.js-specific structure from a template or create an empty IntelliJ IDEA project and configure Node.js in it as described in Starting with an existing Node.js application below.
You can also create a module from an existing Node.js application.
Create a new Node.js application
Select File | New | Project from the main menu or click the New Project button on the Welcome screen.
In the New Project dialog, select JavaScript in the left-hand pane.
In the right-hand pane, choose Express and click Next.
On the second page of the wizard, specify the project folder, the Node.js interpreter, and the package manager (npm or Yarn, see npm, pnpm, and Yarn for details).
For Express applications, specify the express -generator in the express-generator field.
It is recommended that you use npx that downloads and runs the generator. To do that, select npx --package express-generator express from the express -generator list.
Alternatively, open the embedded Terminal (Alt+F12) and type
npm install --g express-generator
and then select the downloaded generator from the express-generator list.Select the template language and the Style Sheet language to use.
When you click Finish, IntelliJ IDEA downloads the necessary dependencies and enables code completion for them as well as for the Node.js core APIs, see Configuring node_modules library and Configuring Node.js Core library for details.
For Express, IntelliJ IDEA creates a run/debug configuration of the type Node.js with default settings and generates a basic Express-specific directory structure.
For Node.js, IntelliJ IDEA just runs the
npm init
command to generate a package.json file.
Create an empty IntelliJ IDEA project
Select File | New | Project from the main menu or click the New Project button on the Welcome screen.
In the New Project dialog, select JavaScript in the left-hand pane.
In the right-hand pane, again select JavaScript and click Next.
On the second page of the wizard, specify the project folder and name and click Finish.
Create a module from an existing Node.js app
Download your application sources and store them on your computer.
From the main menu, select File | New | Module from Existing Sources.
In the dialog that opens, select the location of your application sources.
Learn more from Modules.
Starting with an existing Node.js application
If you are going to continue developing an existing Node.js application, open it in IntelliJ IDEA, configure Node.js in it, and download the required dependencies.
Open the application sources that are already on your machine
Click Open or Import on the Welcome screen or select File | Open from the main menu. In the dialog that opens, select the folder where your sources are stored.
Check out the application sources from your version control
Click Get from VCS on the Welcome screen or select VCS | Get from Version Control from the main menu.
In the invoked dialog, select your version control system from the list and specify the repository to check out the application sources from.
Configure Node.js in a project
In the Settings/Preferences dialog Ctrl+Alt+S, go to Languages and Frameworks | Node.js and NPM.
In the Node Interpreter field, specify the default Node.js interpreter for the current project. IntelliJ IDEA will automatically use it every time you select the
Project
alias from Node Interpreter lists when creating run/debug configurations or configuring Node.js-dependent tools, for example, Prettier or ESLint.Select a configured interpreter from the list or click and configure a new one in the dialog that opens as described in Configuring a local Node.js interpreter. If you select node, the system Node.js version is used.
Select the Coding assistance for Node.js checkbox to configure the Node.js Core module sources as a JavaScript library and associate it with your project. As a result, IntelliJ IDEA provides code completion, reference resolution, validation, and debugging capabilities for
fs
,path
,http
, and other parts of Node.js that are compiled into the Node.js binary.When the configuration is completed, IntelliJ IDEA displays information about the currently configured version.
If you need code completion for Node.js APIs only in some parts of your project, you can configure that using the Manage scopes link. In the Usage dialog that opens, click the relevant directories and for each of them select the configured Node.js Core library from the list. Learn more from Configuring the scope of a library.
Download the project dependencies, do one of the following:
In the embedded Terminal (Alt+F12), type:
npm install
Select Run 'npm install' from the context menu of the package.json file in your project root.
Raspberry Pi is a small, multi-use computer.
With Node.js you can do amazing things with your Raspberry Pi.
What is the Raspberry Pi?
The Raspberry Pi is a small, affordable, and amazingly capable, credit card size computer.
It is developed by the Raspberry Pi Foundation, and it might be the most versatile tech ever created.
Creator Eben Upton's goal was to create a low-cost device that would improve programming skills and hardware understanding.
Due to the small size and price of the device, it has become the center of a wide range of projects by tinkerers, makers, and electronics enthusiasts.
Raspberry Pi and Node.js
The Raspberry Pi has a row of GPIO (General Purpose input/output) pins, and these can be used to interact in amazing ways with the real world. This tutorial will focus on how to use these with Node.js.
What Do I Need?
For this tutorial you need a Raspberry Pi. In our examples we use a Raspberry Pi 3, but this tutorial should work for most versions.
Hardware needed:
- Raspberry Pi computer
- MicroSD memory card (We recommend a class 10 with 16 GB or higher)
- MicroSD to SD memory card adapter (usually included with the MicroSD card)
- Micro USB power supply to power the Raspberry Pi (2.5A or greater recommended)
- WiFi/Ethernet Cable connection for the Raspberry Pi (Not needed for Raspberry Pi 3 as it has built in WiFi)
- A working computer with internet and SD memory card reader (used to get the OS (Operating System) for the Raspberry Pi onto the memory card). In our tutorial we use a Windows computer for this, but you can use a Mac or Linux computer if you prefer
- HDMI monitor, USB keyboard (we need these only temporarily for the first boot of the Raspberry Pi)
For later chapters in this tutorial we will use special sensors or devices that we connect to the Raspberry Pi. We will specify these as special requirements in the relevant chapters.
If you already have a Raspberry Pi set up with Raspbian, internet and enabled SSH, you can skip to the step 'Install Node.js on Raspberry Pi'.
Write Raspbian OS Image to MicroSD Card
Before we can start using our Raspberry Pi for anything, we need to get a OS installed.
Raspbian is a free operating system based on Debian Linux, and it is optimized Raspberry Pi.
Download the latest Raspbian image from https://www.raspberrypi.org/downloads/raspbian/ to your computer.
We use the 'LITE' version in our tutorial, since we are setting the Raspberry Pi up as a headless server (we will connect to it through SSH, without having a keyboard/display connected to it). You can use whichever version you want, but this tutorial is written with the 'LITE' version as its focus.
Insert the MicroSD memory card in your computer (via the SD adapter if needed). Open File Explorer to verify that it is operational.
Etcher is a program for flashing images to memory cards. Download and install Etcher from: https://etcher.io/
Launch Etcher:
Click 'Select image' button and find the Raspbian zip file that you downloaded.
Click the 'Select drive' button and specify the memory card as the target location.
Click the 'Flash!' button to write the image to the memory card.
After Etcher is finished writing the image to the memory card, remove it from your computer.
Set up Your Raspberry Pi
To get the Raspberry Pi ready to boot we need to:
- Insert the MicroSD memory card into the Raspberry Pi
- Connect the USB keyboard
- Connect the HDMI cable
- Connect the USB Wi-Fi adapter (or Ethernet cable). Skip this step if you are using a Raspberry Pi 3
- Connect the micro USB power supply
- The Raspberry Pi should now be booting up
When the Raspberry Pi is finished booting up, log in using username: pi
and password: raspberry
Set Up Network on the Raspberry Pi
If you will use a Ethernet cable to connect your Raspberry Pi to the internet, you can skip this step.
For this section we will assume you have a Raspberry Pi 3, with built in WiFi.
Start by scanning for wireless networks:
This will list all of the available WiFi networks. (It also confirms that your WiFi is working)
Now we need to open the wpa-supplicant file, to add the network you want to connect to:
This will open the file in the Nano editor. Add the following to the bottom of the file (change wifiName
and wifiPassword
with the actual network name and password):
Press 'Ctrl+x
' to save the code. Confirm with 'y
', and confirm the name with 'Enter
'.
And reboot the Raspberry Pi:
After reboot, log in again, and confirm that the WiFi is connected and working:
If the WiFi is working propery, the information displayed should include an IP address, similar to this:
Write down that IP address, as we will use it to connect to the Raspberry Pi via SSH.
Enable SSH, Change Hostname and Password
Now your Raspberry Pi is connected to the internet, it is time to enable SSH.
SSH allows you up use the Raspberry Pi without having a monitor and keyboard connected to it.

(You will need a SSH client for this on your non-Raspberry Pi computer. We use
Open the Raspberry Pi Software Configuration Tool:
You should see a menu like this:
Select option 5 Interfacing Options
:
Select option P2 SSH
, to activate SSH:
Confirm with YES
, to activate SSH:
SSH is now enabled, and you should be in the main menu again.
Select 1 Change User Password
, and follow the instructions to change the password. Choose a secure password, but something you will remember:
After you have finished changing the password, you should be back in the main menu.
Select 2 Hostname
, and follow the instructions to change the hostname:
After you have finished changing the hostname, you should be back in the main menu.
Node.js Server
Now we will close the menu and save the changes:
When selecting Finish
, you will get the option to reboot. Select Yes
to reboot the Raspberry Pi.
You can now unplug the monitor and keyboard from the Raspberry Pi, and we can log in using out SSH client.
Open PuTTY, type in the IP address for your Raspberry Pi, and click Open
:
Log in using the username pi
and the new password you specified.
You should now see a command line like this: (we used w3demopi as our hostname)
You are now able to run your Raspberry Pi in 'Headless-mode', meaning you do not need a monitor or keyboard. And if you have a WiFi connection, you do not need a ethernet cable either, just the power cable!
Install Node.js on Raspberry Pi
With the Raspberry Pi properly set up, login in via SSH, and update your Raspberry Pi system packages to their latest versions.
Update your system package list:
Upgrade all your installed packages to their latest version:
Doing this regularly will keep your Raspberry Pi installation up to date.
To download and install newest version of Node.js, use the following command:
Now install it by running:
Check that the installation was successful, and the version number of Node.js with:
Get Started with Raspberry Pi and Node.js
Now you have a Raspberry Pi with Node.js installed!
Node.js Ide
If you want to learn more about Node.js, follow our tutorial: https://www.w3schools.com/nodejs/
In the next chapter we will get to know the GPIO and how to use it with Node.js.
