Search code examples
cordovaionic-frameworkionic4

-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 ionic@3.2.0 --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
+ cordova@8.1.2
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/cli@7.3.5
├── cordova@8.1.2
├── ionic@4.11.0
└── npm@6.9.0

    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
        + npm@6.9.0
        updated 1 package in 16.501s
        Sshah-Mac-mini:~ sunny$ ionic info
        -bash: ionic: command not found
        Sshah-Mac-mini:~ sunny$

Solution

  • Fixed it

    By editing ~/.bashrc with the following

    export PATH=$PATH:/Users/EDIT_THIS_PUT_YOUR_USER_NAME_HERE/.npm-packages/bin

    sudo npm install -g grpc --allow-root --unsafe

    node-sass : npm rebuild node-sass