Complete Guide to Installing Node.js on Windows: Using the Command Line with Chocolatey or Manual Installation from the Official Website


Install Node.js:

npm comes bundled with Node.js, so you need to install Node.js if you don't have it yet.
Go to the official Node.js website: https://nodejs.org
Download and install the recommended version for most users (LTS).
During the installation, make sure to select the option to add npm to the PATH (this is usually selected by default).

Verify the Installation:

After installing Node.js, open the terminal or command prompt and check if npm and node were installed correctly. Run the following commands:

node -v

npm -v

These commands should return the versions of Node.js and npm, respectively.

A black screen with white text

Node-RED Installation and npm updated to version 11.1.0 :

Once you’ve installed Node.js and verified that npm is working, you can try the command to install Node-RED again:

npm install -g --unsafe-perm node-red

A screenshot of a computer screen

Installing Node.js via Command Line using Chocolatey

Yes, you can install Node.js from the command line, but for that, you'll need to use a package manager like Chocolatey on Windows, which allows you to install software directly from the command line.

Here’s how to do it:

Step 1: Install Chocolatey (if not already installed)

  1. Open PowerShell as an administrator (right-click the PowerShell icon and select "Run as Administrator").
  2. Run the following command to install Chocolatey:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

 

A computer screen shot of a blue screen

Step 2: Install Node.js using Chocolatey

Once Chocolatey is installed, you can easily install Node.js by running the following command in the console:

choco install nodejs-lts

 

A black and white screen

This will install the Long-Term Support (LTS) version of Node.js. Chocolatey will handle the installation and add it to your PATH so you can use it from the command line.

Step 3: Verify Installation

To confirm the installation was successful, run the following commands in the console:

node -v

npm -v

 

A black screen with white text

You should see the versions of Node.js and npm that were installed correctly.

Start Using Node.js

Now you can start using Node.js and npm from your command line. If you need help with project setup

Steps to Start Node-RED:

  1. Open the terminal or command prompt:
    • If you're using Windows, open "Command Prompt."
    • If you're using macOS or Linux, open the terminal.
  2. Run the command to start Node-RED:
    In the terminal, type the following command and press Enter:

node-red

 

A screenshot of a computer program

  1. Wait for Node-RED to start:
    After running the command, Node-RED should begin to start up. You'll see several log messages in the terminal, and the process should take a few seconds.
  2. Access Node-RED in your browser:
    Once Node-RED is up and running, you can access the Node-RED user interface through your web browser. Open the browser and go to the following address:

A screenshot of a computer screen

http://localhost:1880

This will open the Node-RED graphical interface where you can create and manage your automation flows.

A screen shot of a computer

Common Issues:

  • If you have trouble starting Node-RED, make sure Node.js and npm are installed correctly and that the versions are compatible.
  • If port 1880 is being used by another service, you can change the Node-RED port by running the following command before starting Node-RED:

node-red -p [new-port]

Replace [new-port] with the port number you prefer, e.g., 1881.

 

Comentarios

Entradas más populares de este blog