So I have an app that I need to build for android, but on running
ionic cordova prepare android
gives following error in the command prompt
(node:2775) UnhandledPromiseRejectionWarning: CordovaError: Failed to fetch platform [email protected] Probably this is either a connection problem, or platform spec is incorrect. Check your connection and platform name/version/URL. Error: npm: Command failed with exit code 254 Error output: npm WARN checkPermissions Missing write access to /home/{{MYNAME}}/dirname/project-name/node_modules/com-plugins-atcamera npm WARN @ngx-translate/[email protected] requires a peer of @ngx-translate/core@>=10.0.0 but none is installed. You must install peer dependencies yourself. npm WARN @ngx-translate/[email protected] requires a peer of @angular/core@>=6.0.0-rc.0 but none is installed. You must install peer dependencies yourself. npm WARN @ngx-translate/[email protected] requires a peer of @angular/common@>=6.0.0-rc.0 but none is installed. You must install peer dependencies yourself. npm WARN [email protected] requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself. npm WARN [email protected] requires a peer of @angular/core@^4.1.3 but none is installed. You must install peer dependencies yourself. npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
npm ERR! path /home/{{MYNAME}}/gt-Hub/gt-hub-app-pwa/node_modules/com-plugins-gtcamera npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall access npm ERR! enoent ENOENT: no such file or directory, access '/home/{{MYNAME}}/gt-Hub/project-name/node_modules/com-plugins-atcamera' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent
followed by some similar, then some linting errors
I have ran following commands in before to fix another error regarding permission
sudo chmod -R 777 /usr/local/lib/node_modules/cordova
sudo chown -R username ~/.config/configstore/update-notifier-cordova.json
sudo chown -R mehulthanki /usr/local/lib/node_modules/cordova
And lastly to fix above commands
sudo chmod -R 777 usr
I thin I messed up ownership of files and permissions while trying to fix another previous error, which might have been caused due to ionic and cordova being installed with sudo, and actually yo fix that I ran the last chmod command mentioned above, so I could uninstall everything: node, npm, ionic, and cordova and reinstall ionic and cordova without sudo, but now there are other errors..
Any idea how I could fix the permission and ownership issues ?
EDIT On trying run
sudo ionic cordova prepare android
It gives the error
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set