How To Fix: Sudo npm: Command not Found on Linux
Last Updated :
25 May, 2022
"npm: Command not Found" is one of the most basic errors we face while getting started with Javascript. We may get this error while installing the node package manager. Node and npm packages are not related to nodejs and therefore not included in the nodejs package. NPM stands for Node Package Manager. Node.Js is an open-source, Cross-platform, Javascript runtime environment. npm is used to install the different versions of our favorite third-party packages.
This error simply means that npm is not installed on our Linux machine. We need to install npm on our machine.
Fixing Sudo npm: Command not Found on Linux
There are 2 methods through which we can solve this error.
- Download npm from Linux/Ubuntu Repository
- Build NodeJs from the source
Method 1: Download npm from Linux/Ubuntu Repository
To install npm on Linux/Ubuntu, simply execute the following command on our Linux terminal.
sudo apt install npm
After execution, the npm package will be installed on the Linux system and our error will be fixed.
Method 2: Build from Source
This is a bit longer process but this might make us independent of the availability in Linux/Ubuntu Repository. Here is the NodeJs official Repository:
https://github.com/nodejs/node
Note: We must have git installed to build it from the source.
Step 1: See all the available versions of NodeJs.
git ls-remote https://github.com/nodejs/node | grep tags | less
Press 'q' to exit the list.
Step 2: Now clone a specific version of Node (without full history).
git clone --depth 1 --branch v15.11.0 https://github.com/nodejs/node
Step 3: Navigate to the repository using the following command.
cd node
Step 4: Now execute the following commands for configuration and installation.
./configure
make -j12 # We can use j4 or j8 depending on our CPU Count
sudo make install
This might take some time. Once done, we will see a similar result as the Ubuntu Repository result.
Note: Whenever we use sudo, it prompts us for our password. Make sure, in Linux, that our password * isn't visible. Type our password and press Enter. It should work fine.
Similar Reads
How to Fix "pip command not found" in Linux Python has become an essential tool for developers, data scientists, and system administrators due to its versatility and extensive libraries. The 'pip' tool, which is the standard package manager for Python, plays a crucial role in managing Python packages, libraries, and dependencies. However, enc
9 min read
How to Resolve Python Command Not Found Error in Linux Getting the "Python command not found" error in Linux usually means Python is missing or not properly set up on your system. This common issue can be caused by missing installations, incorrect PATH settings, or version mismatches. In this guide, youâll learn the exact steps to fix this error, so you
4 min read
How to Fix apt-get command not found in Linux Starting from Ubuntu 14.04, a new command called apt was introduced, which didnât exist in earlier versions. The apt command combines features from several other package management tools like apt-get and apt-cache, offering a simplified interface with additional features such as colorized output and
6 min read
How To Fix "Bash: Docker: Command Not Found" In Linux Docker has become an essential tool for developers and system administrators to manage and deploy applications efficiently. However, encountering the error message "Bash: Docker: Command Not Found" can be frustrating, especially when you're trying to work with Docker containers. Here, we'll explore
4 min read
How to fix Bash: Command Not Found Error in Linux The "command not found" error is a frequently encountered issue in Linux systems. This error occurs when the system is unable to locate the file specified in the path variable. This error typically occurs when the system cannot locate the command in the directories specified by the path variable.Wha
6 min read
How To Resolve npm Command Not Found Error in NodeJS Node Package Manager (npm) is the default package manager for NodeJS. It allows developers to easily manage libraries and dependencies in their NodeJS projects. It is an essential tool for managing the installation and versioning of packages from the npm registry.The npm: command not found error hap
4 min read