Cause: This error occurs when Node.js is not properly installed on your system or the path is not correctly set.
please subscribe to my YouTube channel to support my channel and get more web development tutorials.
Solution:
Step-by-Step Solution
-
Download Node.js:
- Visit the official Node.js website.
- Choose the appropriate installer for your operating system (Windows, macOS, or Linux).
- Download the installer and follow the on-screen instructions to install Node.js.
-
Verify Installation:
- Open your terminal (Command Prompt on Windows, Terminal on macOS/Linux).
- Run the following command to check if Node.js is installed correctly:
node -v
- If Node.js is installed, this command will display the version of Node.js installed. For example,
v16.0.0
.
- Setting the Path (if the above steps don’t work):
-
For Windows:
- Open the Start menu and search for
Environment Variables
. - Click on
Edit the system environment variables
. - In the System Properties window, click on the
Environment Variables
button. - Under
System variables
, find thePath
variable and clickEdit
. - Click
New
and add the path to the Node.js installation directory. For example,C:\Program Files\nodejs\
. - Click
OK
to save the changes and close all windows. -
Restart your Command Prompt and verify the installation again with:
node -v
- Open the Start menu and search for
-
For macOS/Linux:
- Open your terminal.
-
Open your shell profile file in a text editor (
.bashrc
,.bash_profile
,.zshrc
, etc. depending on your shell):
nano ~/.bashrc
3. Add the following line to the file to include the Node.js installation directory in your PATH:
```bash
export PATH=$PATH:/usr/local/bin/node
```
4. Save the file and reload the changes with:
```bash
source ~/.bashrc
```
5. Verify the installation again with:
```bash
node -v
```
This should resolve the node: command not found
error and successfully install Node.js on your system.
please subscribe to my YouTube channel to support my channel and get more web development tutorials.
Follow and Subscribe:
- Website: Dipak Ahirav
- Email: dipaksahirav@gmail.com
- YouTube: devDive with Dipak
- LinkedIn: Dipak Ahirav
- Instagram: devdivewithdipak
Happy coding! 🚀
Top comments (2)
I'm a Linux user and I had this same problem with Node. Changing the PATH variable ended up deleting my graphics system and I had to reinstall the OS to recover.