Error: EACCES: permission denied, unlink - when run $ ionic start

Hi, I am just getting started with ionic, and I am now facing a blocker in a very early step to run ionic.

I am using OS: Linux Mint 18 Cinnamon 64 bit
Node version : v10.0.0 (installed from NVM without root access)
NPM version : 5.6.0 (installed from NVM without root access)

I am following this tutorial:
https://coursetro.com/posts/code/36/Installing-Ionic-2-&-Starting-a-Project

I install ionic by:

$ npm install -g ionic cordova

It returns this:

home/brian/.nvm/versions/node/v10.0.0/bin/cordova → /home/brian/.nvm/versions/node/v10.0.0/lib/node_modules/cordova/bin/cordova
/home/brian/.nvm/versions/node/v10.0.0/bin/ionic → /home/brian/.nvm/versions/node/v10.0.0/lib/node_modules/ionic/bin/ionic
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3 (node_modules/ionic/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})

  • cordova@8.0.0
  • ionic@3.20.0
    added 677 packages in 16.679s

Then I checked if cordova and ionic is installed by $ ionic -v , and it returns

3.20.0

  • ionic is installed despite of the WARN message.

I then try to run the next step of tutorial:

$ ionic start firstProject blank

Then this error show up:

? The directory firstProject contains file(s) that could conflict. Would you like to overwrite the directory with this new project? Yes
:heavy_multiplication_x: Creating directory ./firstProject - failed!
Error: EACCES: permission denied, unlink ‘/home/brian/firstProject/.editorconfig’

I have tried to give permission to that path by:

$ sudo chown -R brian /home/brian/firstProject/.editorconfig

But still, the same error persists when I run $ ionic start firstProject blank

I also have tried running the command using root $ sudo ionic start firstProject blank, but it returns

sudo: ionic: command not found.

I have tried to install ionic without global attributes, but the result is that it cannot be installed because of that npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3

Has anyone been able to resolve this kind of issue? Any help would be appreciated. Thanks!

I have just solved the problem.

I realized that the folder firstProject was locked. So my recommendation if you want to use node and npm, better to install it using NVM so you don’t install it with root access.


Let me tell how to recreate the issue

So before I actually install Node and NPM from NVM (Node Version Manager), I first install it from package manager using sudo (root access) using this command (I followed this reference):

$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - 
$ sudo apt-get install -y nodejs

Which then causes all my following npm commands should use sudo (for root access).

So, when I run this command (following this tutorial):

$ npm install -g ionic cordova

I was unable to install it:

npm WARN checkPermissions Missing write access to /usr/lib/node_modules

I need to use root access to install it:

$ sudo npm install -g ionic cordova

Which then makes ionic and cordova to always run in root access – I think you should avoid it!

So continue from here, I run the next command following the tutorial:

$ ionic start firstProject blank

Which then makes the folder /firstProject/ requires a root access (see image attached). And continuing using sudo is not a good idea as sometimes ionic runs another command while running it’s process.
Folder locked

In conclusion, the installation of Node and NPM using sudo is not a good idea. I don’t know yet if there is a good reason of using sudo, if you know why, please reply a comment.


So following my case,

I have actually done it correctly:

  1. Install Node and NPM from NVM
  2. Install ionic and cordova without sudo (root access)
  3. Simply run the ionic start command e.g. ionic start firstProject blank; but first make sure that there is no existing locked folder with this name (firstProject).

I hope it helps solve your similar issues.