Ubuntu Linux 20.04.
Setting up a new machine I installed the lastest version of npm. At the time that was v17.4.0. For some reason it also has folders for v17.3.0 in /home/dougi/.nvm/versions/node.
I then found I needed the LTS version for certain things and so used nvm to install v16.13.2.
I uninstalled v17.4.0 with nvm uninstall v17.4.0 which removed all traces of v17.4.0, but left the folders for v17.3.0 (no idea why they are there).
Today I installed ionic cli with npm install -g @ionic/cli and it puts the ionic files in /home/dougi/.nvm/versions/node/v17.3.0/bin. When I run ionic start I get Command 'ionic' not found.... Using nvm ls I can see that I am currently using v16.13.2, so I'm unsure why ionic is being installed to the v17.3.0 folder. I assume that this is why the ionic command is not recognised. Output from nvm ls is:
I also note a lot of red, which may be bad?
What I am doing wrong please?
How do I get rid of the v17.3.0 folders (I assume not good to just delete them)?
How do I get ionic to install and be recognised under node v16.13.2?
Thanks!
2 Answers
Try to delete that manually using:
cd ~/.nvm/versions/node
sudo rm -rf v17.4.0/and also make sure that you are actually switched to the 16 version:
nvm install 16
nvm use 16
nvm alias default 16 15 When running nvm to manage node you don't want to use the global prefix in npm as nvm needs to manage that.
I had a global npm prefix set and so all npm installations going to the path of the node version in the npm prefix.
You can check your npm global prefix with:
npm root -g
Deleting that prefix then enables nvm to decide which node version to install into. To delete the global npm prefix:
npm config delete prefix
nvm now worked properly and when I ran npm install -g @ionic/cli it properly installed to the version of node currently selected in nvm. Phew!
Thank you to @sina.ce for his help in getting me there!