Ionic, npm, and cordova commands all require sudo to work

Sudo, according to the views of what I saw in some forums, is the reason that I get an error message when starting sudo ionic emulate ios in this message New for ion-dependent assembly for ios (9) on El Capitan and sudo ionic is required , deprecated npmconf . (I control El Capitan btw).

Whenever I need to use the ionic, npm or cordova command, I always need to put sudo in front of me, otherwise I will get a "bash not found" error. I tried using this fix https://www.npmjs.com/package/npm-sudo-fix , but it does not work. This is what happens in the log:

Dylans-MBP: Ionic Projects Dylan $ sudo npm install -g npm-sudo-fix Password: / usr / local / bin / npm -sudo-fix β†’ / usr / local / lib / node_modules / npm-sudo-fix / index. js npm-sudo-fix@0.1.3 / usr / local / lib / node_modules / npm-sudo-fix └── spawny@0.0.1 ( cmdify@0.0.4 ) Dylans-MBP: Ionic projects Dylan $ sudo npm-sudo-fix chown: / users /root/.npm: no such file or directory

+5
source share
1 answer

Finally a solution came up playing with permissions! I hope I haven’t scored anything. (I'm a noob btw terminal.) Anyway, here is the solution.

Run this code here in the terminal (you may need to run cd .. before you start)

 sudo chown -R $USER /usr/local/ 

This changes the permissions of each thing inside the local folder (hence -R , which means recursive). (I found this line somewhere on ion forums).

Now you need to reinstall cordova and ionic

 sudo npm install -g cordova sudo npm install -g ionic 

For me, anyway, after that I can type ionic and not get any errors. I get this in the terminal if I run cordova , though.

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

What I did to fix this is to do it (after opening a new terminal window):

 sudo chown -R $USER Dylan 

(Dylan is my user folder, replace it with yours. In addition, you may need to run cd .. before running this line. And this fixes the permissions for this configuration file. Now running cordova works without errors! This error may return, so you need to run this line of code again.

Hope this helps someone!

+10
source

Source: https://habr.com/ru/post/1240898/


All Articles