Ubuntu says No command 'ionic' found after installing Ionic
No command 'ionic' foundShort answer
The shell finds ionic only if the Ionic CLI is installed globally and npm's global bin folder is on PATH. The package is @ionic/cli, not the old ionic package. Check what sits in npm's global folder, then install the right package, add the bin folder to PATH, or reinstall it under the Node.js version you now use.
Fix it fast
1Find out which cause you have
Find npm's global folder and see which packages it holds. The result tells you whether the CLI is missing or only hidden.
npm prefix -g ls "$(npm prefix -g)/lib/node_modules"2Match what you see, then jump to its fix
- 1
The listing has no @ionic folder, or it shows a folder named ionic.The Ionic CLI is not installed, or the old package is installedFix - 2
The @ionic folder exists in the listing, but command -v ionic prints nothing.npm's global bin folder is not on PATHFix - 3
ionic worked before. After nvm use or a new terminal, node -v shows a different version and the listing no longer has @ionic.You installed it under another Node.js version (nvm)Fix
- 1
What does the error look like?
No command 'ionic' foundionic: command not found
Cause 1 of 3
The Ionic CLI is not installed, or the old package is installed
1Check
The CLI is published as @ionic/cli. Ionic's docs say an older install must be removed first because the package name changed, so a global package called ionic is the old one.
ls "$(npm prefix -g)/lib/node_modules"2Fix
Remove the old package if it is there, then install @ionic/cli. If npm stops with an EACCES error, do not use sudo: set up npm's global folder in your home directory (see the next cause).
npm uninstall -g ionic
npm install -g @ionic/cli3Verify
The shell now finds the command.
command -v ionicConfirmed by ionicframework.com
Cause 2 of 3
npm's global bin folder is not on PATH
1Check
npm links the executables of global packages into the bin folder under its prefix, and that folder must be on PATH. Compare PATH with the prefix.
echo "$(npm prefix -g)/bin"
echo "$PATH" | tr ':' '\n'2Fix
Add that bin folder to PATH. npm's own guide for avoiding sudo moves the prefix to ~/.local and puts ~/.local/bin on PATH in ~/.profile. With zsh, also source ~/.profile from ~/.zprofile.
npm config set prefix ~/.local
echo 'PATH=~/.local/bin:$PATH' >> ~/.profile
source ~/.profile
npm install -g @ionic/cli3Verify
Open a new terminal and look for the command.
command -v ionicConfirmed by docs.npmjs.com
Cause 3 of 3
You installed it under another Node.js version (nvm)
1Check
With nvm, each installed Node.js version has its own global packages folder under ~/.nvm/versions/node. A different active version, or a new shell that starts with the default alias, uses another folder.
node -v
npm prefix -g2Fix
Reinstall the CLI under the version you want to use, and set that version as the default for new shells.
nvm use node
npm install -g @ionic/cli
nvm alias default node3Verify
Open a new terminal and look for the command.
command -v ionicConfirmed by raw.githubusercontent.com
How do I stop it coming back?
- Install global CLIs without sudo, with npm's prefix in your home directory, so the folder is yours and on PATH.
- Pick one Node.js manager (nvm or the system package) and stay with it.
- Set the nvm default alias, so new terminals and editors start with the Node.js version that has your global tools.
- Keep a short setup note in the repository with the install command for the Ionic CLI.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Mobile apps
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile apps
adb tcpip 5555 fails because no device is found
adb: more than one device/emulator
adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.
4 causes, each with a fixMobile apps
The Android Emulator says /dev/kvm is not found
KVM acceleration can NOT be used
The emulator wants a hypervisor and cannot find one.
4 causes, each with a fixMobile apps
The emulator says the GPU driver is unsupported and falls back to software
vulkan-1.dll cannot be found
The emulator picks a graphics mode when it starts.
4 causes, each with a fix