Unable to install Ionic on WSL


#1

I am running Bash/WSL on Windows 10.

After installing NodeJS v6.10.3 (which includes npm 3.10.10), both those programms are available. I can install typescript for instance with:

sudo npm install -g typescript

However I keep getting an error when running :

sudo npm install -g ionic

npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "ionic"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! path /usr/lib/node_modules/.staging/superagent-203d79eb
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename

npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/superagent-203d79eb' -> '/usr/lib/node_modules/ionic/node_modules/superagent'
npm ERR!     at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR!     at /usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:264:29
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/superagent-203d79eb' -> '/usr/lib/node_modules/ionic/node_modules/superagent'
npm ERR!     at Error (native)
npm ERR!  { Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/superagent-203d79eb' -> '/usr/lib/node_modules/ionic/node_modules/superagent'
npm ERR!     at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR!     at /usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:264:29
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/superagent-203d79eb' -> '/usr/lib/node_modules/ionic/node_modules/superagent'
npm ERR!     at Error (native) parent: 'ionic' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/lib/node_modules/npm-debug.log
npm ERR! code 1

I first tried to run sudo npm install -g ionic cordova but got a similar error.

I tried on 2 different PCs, one desktop running Windows 10 Pro 64bits, the other a Dell laptop running Windows 10 Family 64 bits.

I know WSL is very new, but it would be great if we could use it to develop ionic apps.

Please ask for more info if you think you can help.


#2

I would recommend using nvm to manage your node installation, and never running npm as root.


#3

Hi @rapropos, thanks for your response.

I am not running these commands as root (though i used sudo for the global install). In the WSL bash, you automatically create a normal user when first installing Ubuntu.

That doesn’t help me much though :wink: since node and npm both work fine.


#4

What he means is: Use nvm to install node, then you don’t even need sudo npm anything ever, not even for global installs. Maybe this solves your problem automatically.