android – ionic update-notifier-cordova.json' You don't have access to this file-ThrowExceptions

Exception or error:

I am trying to run ionic on iOS, but it throws an error.

What happened?

ionic run ios
    /usr/local/lib/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:53
                    throw err;
                          ^
    Error: EACCES, permission denied '/Users/jiahongl/.config/configstore/update-notifier-cordova.json'
    You don't have access to this file.

        at Error (native)
        at Object.fs.openSync (fs.js:500:18)
        at Object.fs.readFileSync (fs.js:352:15)
        at Object.create.all.get (/usr/local/lib/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:34:26)
        at Object.Configstore (/usr/local/lib/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:27:44)
        at new UpdateNotifier (/usr/local/lib/node_modules/cordova/node_modules/update-notifier/index.js:34:17)
        at module.exports (/usr/local/lib/node_modules/cordova/node_modules/update-notifier/index.js:123:23)
        at checkForUpdates (/usr/local/lib/node_modules/cordova/src/cli.js:64:20)
        at cli (/usr/local/lib/node_modules/cordova/src/cli.js:114:5)
        at Object.<anonymous> (/usr/local/lib/node_modules/cordova/bin/cordova:41:1)

Error Message

How to solve:

I just changed permission of the file update-notifier-cordova.json by below command:

sudo chmod -R 777 '/Users/anand.d.gupta/.config/configstore/update-notifier-cordova.json'

And this fixed the problem.

###

delete the file update-notifier-cordova.json from this location problem solved, it’s nothing but just a config file

###

Deleting the file wont be a right option, the following approach worked out for me. The root cause of this issue is because of the Cordova-cli permissions.

Step 1: Uninstallcordova and install it again.

 sudo npm remove -g cordova 

Step 2: Install with the following command

sudo npm install -g --unsafe-perm=true cordova

Make sure it installs the recent version, by typing $ ionic info you can see the Cordova CLI versions

Step 3: Secure the permissions for the following folders

sudo chown -R <username> /Users/<username>/.config/configstore/
sudo chown -R <username> /Users/<username>/.cordova/

ionic build ios  - Should work like charm

###

In my project, this problem has been fixed with this lines:

sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config

###

changed permission to this folder

sudo chown -R yourusername /Users/yourusername/.config/configstore/

Leave a Reply

Your email address will not be published. Required fields are marked *