A guide to install Ionic 2 in Ubuntu 14.04

I have some issues with running Ionic in Ubuntu. My attempts to troubleshoot didn’t go well. I have asked on multiple forums, even here ( Unable to make Ionic work in Ubuntu 14.04 ) without success.

Can someone guide me install Ionic 2 in Ubuntu 14.04 please ?

I installed on Ubuntu. What’s your question?

1 Like

basically it

install Git

After you install Node Version Manager

Now install the latest version of Node with the nvm (v5.10.1 today) and update the npm (npm i -g npm)

So you can do a npm install -g ionic@beta cordova

1 Like

Thank you @allpref . I will try and update.

@skydive

Could you please look into my link in first post ? Ionic 1 is not working for me. Not sure what is messed up.

@allpref , @skydive

I get the following error ( was the same with Ionic 1 as well )

ionic start myApp1 blank
module.js:327
    throw err;
    ^

Error: Cannot find module 'archiver'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/ionic/node_modules/ionic-app-lib/lib/utils.js:3:16)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)

After using npm install -g ionic@beta cordova , I got the following error in the end

npm ERR! Please include the following file with any support request:
npm ERR!     /home/dna/npm-debug.log

it’s because is the ionic 1 error.

to start a project with ionic 2 (note the –v2):
ionic start MyIonic2Project tutorial --v2

1 Like

It seems to me that’s kind of messed up your node installation.

the best thing to do is to give a search on google to completely remove the node and everything attached to it (as npm, nvm, if you installed ruby, rails, etc …).
then install again put as before, leaving a cleaner and easy to update installation.

1 Like

@allpref , sorry for bothering you. My experience with node commands are poor. Would be very nice if you can give me the commands to do it. Thanks.

I really have no idea :slight_smile: I never completely remove node.

I know the links that I sent just above work well because at least 2 times a month format my machine (stupid habit I have) and that model has always worked.

a quick search here returned this link on stackoverflow, commands and apparently works for the votes they received.

1 Like

I used

  sudo apt-get remove nodejs
  
  sudo apt-get remove npm

&

to remove, delete, or uninstall nvm - just remove the $NVM_DIR folder (usually ~/.nvm)

I hope I have removed npm, nodejs and nvm. Will start from the beginning now

@allpref @skydive

I am getting this after completely removing and reinstalling nodejs and npm

npm ERR! Linux 3.13.0-85-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "ionic@beta" "cordova"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.3
npm ERR! path /usr/lib/node_modules/.staging/abbrev-0f758453
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename '/usr/lib/node_modules/.staging/abbrev-0f758453' -> '/usr/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev'
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/lib/node_modules/.staging/abbrev-0f758453' -> '/usr/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR!     /home/dna/npm-debug.log

`

first makes a npm update, the error shows that 3.8.3 is installed, mine is the 3.8.6 … may be that makes any difference (or not).

try with sudo, I do not need to use sudo in my installation, but i dont know yours.

sudo npm i -g npm

now removes ionic and the cordova

sudo npm remove -g ionic@beta cordova or sudo npm remove -g ionic cordova (i dont know for sure if the remove needs the @beta.

then makes a clean cache in

npm cache clean

and try again

sudo npm install -g cordova ionic@beta

also take a look here too

1 Like

I don’t know what I am doing wrong. Everything went well this time. No errors, warning. But the same error again :frowning:

ionic start MyIonic2Project tutorial --v2
module.js:341
throw err;
^

Error: Cannot find module ‘archiver’
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object. (/usr/local/lib/node_modules/ionic/node_modules/ionic-app-lib/lib/utils.js:3:16)
at Module._compile (module.js:413:34)
at Object.Module._extensions…js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)

:pensive: sorry, but this time I do not even know how to try to help. I’ve never seen this error and what googled here ‘module.js: 341 throw err;’ and ‘Error: Can not find module’ archiver ‘’ showed that several people had this error.

I think it’s for these reasons that I’m slightly paranoid and I’m always re-installing Linux :laughing: (edit: my bad, I wrote in portuguese)

1 Like

No problem. Many thanks for the help so far. :disappointed_relieved:

Do you think reinstalling Ubuntu will solve the issue ?

Hi
I recently installed Ubuntu and Ionic. I dont know what I did wrong, but could not get Node running using packages, so used the direct download stuff from the nodejs.org site and then Node was doing fine.

So what I did: clean install Ubuntu, installed Node using nodejs.org installer and then did sudo npm install -g ionic@beta.

Not sure if this helps but at least less effort compared to clean Ubuntu install.

Regards

Tom

1 Like

I can not advise you to do this, I’m sure if I do that there are people who will want to give me a beating.

1 Like

From my experience it’s very important to have right versions (best the latest) of everything. I have version 4.4.3 of nodejs and version 2.15.1 of npm. Mine are not the latest, but it works for me, so I don’t touch it unless I have very important reason.

To remove old version use:
sudo apt-get --purge autoremove node

It will remove all dependencies too.

This is how you install the latest of nodejs:

sudo apt-get install -y build-essential
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo ln -s /usr/bin/nodejs /usr/bin/node

Hope it helps.

1 Like

In general, my suggestion at this point would be to try to remove all involved packages (nodejs, npm, curl, ionic, etc I mean EVERYTHING). Use “–purge autoremove” option, since it clears the environment better (at least it worked for me). After that install from clean. I’m not sure what exactly is going on with your environment, but it seems pretty much messed up with old installations.

Sorry I couldn’t help more.

1 Like