-bash: ionic: command not found (Not able to install any version)

I am trying to install ionic globally.

sudo npm install -g cordova ionic AND npm install [email protected] --save

I tried both the commend it execute successfully.

But when i run ionic info it shows -bash: ionic: command not found

Can anyone help me?

EDIT : Same thing happen when i install cordova

    sudo npm install -g cordova
Password:
/Users/hardik/.npm-packages/bin/cordova -> /Users/hardik/.npm-packages/lib/node_modules/cordova/bin/cordova
+ [email protected]
updated 1 package in 7.011s
Sshah-Mac-mini:node_modules sunny$ cordova -v
-bash: cordova: command not found

Terminal Log

  Sshah-Mac-mini:~ sunny$ npm list -g --depth=0
/Users/hardik/.npm-packages/lib
├── @angular/[email protected]
├── [email protected]
├── [email protected]
└── [email protected]

    Sshah-Mac-mini:~ sunny$ npm root -g
    /Users/hardik/.npm-packages/lib/node_modules


       ╭───────────────────────────────────────────────────────────────╮
       │                                                               │
       │       New minor version of npm available! 6.7.0 → 6.9.0       │
       │   Changelog: https://github.com/npm/cli/releases/tag/v6.9.0   │
       │               Run npm install -g npm to update!               │
       │                                                               │
       ╰───────────────────────────────────────────────────────────────╯

        Sshah-Mac-mini:~ sunny$ npm install -g npm
        /Users/hardik/.npm-packages/bin/npm -> /Users/hardik/.npm-packages/lib/node_modules/npm/bin/npm-cli.js
        /Users/hardik/.npm-packages/bin/npx -> /Users/hardik/.npm-packages/lib/node_modules/npm/bin/npx-cli.js
        + [email protected]
        updated 1 package in 16.501s
        Sshah-Mac-mini:~ sunny$ ionic info
        -bash: ionic: command not found
        Sshah-Mac-mini:~ sunny$

Solution 1:

This command show globally available modules in npm

npm list -g --depth=0

if you cant see ionic cordova in this list it means both packages are not installed globally.

check your global installation path by

npm root -g

check if your ionic and cordova installed in this directory or not. if you have tried path changing in first answer and still not working then uninstall node and install latest recommended version of node.

then install

npm install -g ionic
npm install -g cordova 

Solution 2:

The first thing after the installation try this,

sudo ln -s /home/USER/npm/bin/ionic /usr/bin/ionic

If still getting the error, you are using Old version of Ionic Uninstall it and Reinstall it again.

> npm uninstall -g cordova

> npm uninstall -g ionic

Then just reinstall

> npm install -g cordova
> npm install -g ionic

if still, it gives errors another solution is Go to user/.ionic folder and remove all files then install ionic again by using the following commands.

> npm install -g ionic