It can be quite frustrating when you find yourself unable to get the Angular CLI version even though all the requirements are installed. You might have Node, NPM, and Angular all set up, but when you run ng -v
, you get an error message that doesn’t make any sense. Not to worry, we’ve got your back! In this blog post, we’ll provide a step-by-step guide on how to resolve this issue and get back to building fantastic Angular applications.
Understanding the Problem
First, let’s understand the problem. You have all the requirements installed, and running the which
command shows that they all exist in your /usr/local/bin
directory. However, when you try to get the Angular CLI version, you encounter an error message like this:
$ ng -v Node.js version v11.8.0 detected. The Angular CLI requires a minimum Node.js version of either v10.13 or v12.0. Please update your Node.js version or visit https://nodejs.org/ for additional instructions.
This error message indicates that the Angular CLI isn’t compatible with your installed Node.js version. Let’s see how we can fix this issue.
Step 1: Uninstall the Angular CLI
Before installing a compatible version of Angular CLI, you should uninstall the current version. Run the following command in your terminal:
npm uninstall -g @angular/cli
Step 2: Update Node.js to a Compatible Version
As the error message suggests, you need to update your Node.js version to either v10.13 or v12.0 or above. You can check the current Node.js version by running:
node -v
If the version isn’t compatible, you should update it. We recommend using NVM (Node Version Manager) for macOS/Linux or nvm-windows for Windows. NVM allows you to switch between multiple Node.js versions easily.
Updating Node.js with NVM
To update Node.js using NVM, run the following commands:
nvm install 12 nvm use 12
Now, check your Node.js version again to confirm the update:
node -v
Step 3: Install the Angular CLI
With the compatible Node.js version installed, you can now install the Angular CLI. Run the following command:
npm install -g @angular/cli
Step 4: Verify the Angular CLI Installation
Finally, verify that the Angular CLI has been installed correctly by running:
ng --version
You should now see the correct Angular CLI version, and the error message should be gone. You’re all set to continue developing your Angular applications!