Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run ionic. receives "No command 'ionic' found"

I want to start using the ionic framework, but unfortunately I'm already failing on the first step.

I am running Ubuntu 13.04 and I have node v0.10.25 installed. I've installed ionic, at described in their docs:

sudo npm install -g cordova
sudo npm install -g ionic

The installation went well, no errors or warnings, but after the installation I type

ionic

and I get the error:

No command 'ionic' found, did you mean:
 Command 'ionice' from package 'util-linux' (main)
 Command 'sonic' from package 'sonic' (universe)
ionic: command not found

I'm pretty new to ubuntu so I might have something not configured correctly, but I can't find what.

Thanks

like image 969
Guy Sopher Avatar asked Aug 04 '14 21:08

Guy Sopher


5 Answers

for some of you, the two answer above might not work. here's a more general solution for situation where you see "XX" command not found

first check your npm root and npm root -g the result for the npm root -g should be something like "/usr/local". if it's not, then you found your problem.

change it by:

npm config set prefix /usr/local

then npm root -g should give you something like /usr/local/lib/node_modules . Then go ahead re-install everything with -g you will be good to go!

like image 152
Martian2049 Avatar answered Oct 10 '22 12:10

Martian2049


Well, I found it finally.

The ionic installation was at /home/guy/npm/bin/ionic, not at /usr/bin/ionic at it should be.

Solved it with:

sudo ln -s /home/guy/npm/bin/ionic /usr/bin/ionic
like image 34
Guy Sopher Avatar answered Oct 10 '22 13:10

Guy Sopher


I solved the problem by cd to my root. Then install ionic as root admin.

$ sudo npm install -g cordova ionic

then run

$ ionic

to see if it's working.

like image 42
Sabba Keynejad Avatar answered Oct 10 '22 12:10

Sabba Keynejad


Someone might run into this after trying to change the global library directory of npm to a folder they have permissions to write to in order to be able to install global libs without root permissions.

In that case you might have forgotten to add the new folder to you PATH environment variable.

The whole process of fixing Permissions can be found here.

in case that source disappears here is a copy of the steps:

There are times when you do not want to change ownership of the default directory that npm uses (i.e. /usr) as this could cause some problems, for example if you are sharing the system with other users.

Instead, you can configure npm to use a different directory altogether. In our case, this will be a hidden directory in our home folder.

  1. Make a directory for global installations:

    mkdir ~/.npm-global

  2. Configure npm to use the new directory path:

    npm config set prefix '~/.npm-global'

  3. Open or create a ~/.profile file and add this line:

    export PATH=~/.npm-global/bin:$PATH

  4. Back on the command line, update your system variables:

    source ~/.profile

Test: Download a package globally without using sudo. npm install -g jshint

Instead of steps 2-4 you can also use the corresponding ENV variable (e.g. if you don't want to modify ~/.profile):

NPM_CONFIG_PREFIX=~/.npm-global npm install -g jshint

if you just follow these steps and reinstall all the Global libs there is a good chance that it will start working for you anyways...

Just remember that if you do this, you will save your global libs into the folder created in step 1 instead of the default location in /usr/local or just /usr (depending on your OS flavor i guess?)

like image 35
Oli Avatar answered Oct 10 '22 13:10

Oli


First Solution

I recently ran into this issue and the only solution that worked for me was to uninstall both ionic and cordova.

npm uninstall -g cordova
npm uninstall -g ionic

Then just reinstall

npm install -g cordova
npm install -g ionic 

Second Solution

I ran into this issue again! This time check your environmental variables.

Run npm bin -g and check if the path returned is in your environmental variables. For me, it prompted that it was not found in the terminal output. I added that path to the environmental variables and restarted the terminal. From there everything started to work again. (source)

like image 9
Niles Tanner Avatar answered Oct 10 '22 14:10

Niles Tanner