Why i am using always SUDO

ionic cordova platform rm ios
> cordova platform remove ios
    throw err

Error: EACCES: permission denied, open '/Users/kalemmacbookpro/Library/Preferences/insight-nodejs/insight-cordova.json.1908726309'
    at Object.openSync (fs.js:458:3)
    at Function.writeFileSync [as sync] (/usr/local/lib/node_modules/cordova/node_modules/conf/node_modules/write-file-atomic/index.js:212:13)
    at Conf.set store [as store] (/usr/local/lib/node_modules/cordova/node_modules/conf/index.js:142:19)
    at new Conf (/usr/local/lib/node_modules/cordova/node_modules/conf/index.js:44:14)
    at new Insight (/usr/local/lib/node_modules/cordova/node_modules/insight/lib/index.js:40:35)
    at new RelentlessInsight (/usr/local/lib/node_modules/cordova/src/telemetry.js:31:1)
    at Object.<anonymous> (/usr/local/lib/node_modules/cordova/src/telemetry.js:39:15)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32) {
  errno: -13,
  syscall: 'open',
  code: 'EACCES',
  path: '/Users/kalemmacbookpro/Library/Preferences/insight-nodejs/insight-cordova.json.1908726309'
[ERROR] An error occurred while running subprocess cordova.
        cordova platform remove ios exited with exit code 1.
        Re-running this command with the --verbose flag may provide more information.

i have mac book pro and my operation system macos. i am coding with ionic and i have to use all command with SUDO. i dont want do this.

but if i use this code with SUDO , everything is normal. how can i use all ionic code without SUDO ? please help me, thanks.

By never using sudo, even once, in your Ionic coding and building. Once you ever do it, you are likely to screw up file permissions all over the place.

Install and use nvm, and all your node.js environments will live in your user home directory. There is never any need to run anything Ionic-related with elevated privileges.

i want to use onesginal and if i try platform add ios, i am getting always cocoapods error, you can not cocoapods as root. if i use SUDO when adding ios platform. if i dont use SUDO, so i am getting error EACCESS

You need to find the offending files and chown them back to your regular user.

sudo chown -R $(whoami) ~/.npm
1 Like