Netlify CLI, permission denied to config file. Can't run any command

I installed the netlify-cli package globally using npm install netlify-cli -g , the installation completed. After that I ran netlify command and got this error

Error: EACCES: permission denied, open '/Users/{USER_FOLDER}/Library/Preferences/netlify/config.json.2846113261' You don't have access to this file.

To Reproduce

Steps to reproduce the behavior:

  1. Run npm install netlify-cli -g
  2. Installation succeed
  3. Run netlify
  4. Gets the error about not having access to config.json file
1 Like

hi there, thats definitely frustrating! does your terminal instance have suffcient privileges for this to run properly? Are you running it as an administrator if you are on windows?

Hello
I am facing exactly same issue here

Try this solution. This fixed for me Access denied to config file after installing CLI when running netlify command Ā· Issue #4243 Ā· netlify/cli Ā· GitHub

1 Like

It worked! thank you!

1 Like

Firstly, sudo npm install -g netlify-cli command produced an empty ā€œnetlify folderā€.
So, thereā€™s no config.json file in my directory. This time I ran the command the ā€œ/Users/aminarahmanā€ directory. Please help me. I also tried to run the installation command from my project directory.


Here is another attempt. I uninstalled first and then tried npm install -g netlify-cli and sudo npm install -g netlify-cli. Here are the errors I get. The ā€œconfig.jsonā€ file is empty.

This is not a CLI issue. Itā€™s your OS not allowing CLI to write to some directories. You might have to check all permissions across your device.

Screenshot 2023-03-26 at 2.26.49 PM
Here it is. Thank you for the reply. How can I change the permission and which one?

Hi, @amina.rahman. Have you tried the two workarounds in these two comments?

If not, I would start with these two above.

Hello, Luke, I saw those and tried the first one earlier. I somehow managed to install using sudo npm install -g netlify-cli once, where I got the empty ā€œconfig.jsonā€ file. Here in the screenshot, I deleted my current ā€œnetlifyā€ directory as said in the first link and you can see the rest.

I also tried to manually change the permission (Read&Write for all) as said in the second link.

Then I tried running netlify. But got this
" Error: EACCES: permission denied, open ā€˜/Users/aminarahman/Library/Preferences/netlify/config.jsonā€™
You donā€™t have access to this file."

Maybe I donā€™t understand the instructions given in these solutions. I am trying to follow everything suggested in those links.

Please help me. Iā€™ve tried as much as I could. And itā€™s something that I donā€™t know who else can help me other than the Netlify team. :sob:

Iā€™d suggest that your installation as root caused the problem, and youā€™ll need to keep cleaning up from that. This is not a netlify problem; this is something you broke and need to fix, that we canā€™t directly advise on.

What I can tell is that according to the error message, youā€™ll likely
need to at least remove the file that the error complains about you not having permissions on: /Users/aminarahman/Library/Preferences/netlify/config.json

1 Like

Thank you for the hint. I had to uninstall Node. In my case, then installed NVM via Homebrew, then installed Node again. This solved the issue. This one link helped me to solve my problem eventually.

Thanks for coming back and letting us know you solved your problem!

hi guys I have the same permission denied problem after trying sudo/npm/homebrew npm install -g netlify-cliā€¦
I even try manually change the permission of netlify file in /Users/Lizzie/Library/Preferences/netlify/`. still not workingā€¦

I eventually find the solution and it works for me:

step1:
Resolving EACCES permissions errors when installing packages globally

step2: make sure you donā€™t have the netlify folder yet.(delete the one you have downloaded)
go for all steps ( if you cant install source ~./profile , then you could just jump to NPM_CONFIG_PREFIX=~/.npm-global`

step3: re-install : npm install -g netlify-cli

:smiley: hope it helps

Thanks for sharing @LizzieTse0617