Adding platform and build

I’m getting these errors while running ionic platfom add android

Error: spawn EACCES
at exports._errnoException (util.js:746:11)
at ChildProcess.spawn (child_process.js:1162:11)
at Object.exports.spawn (child_process.js:995:9)
at Object.exports.spawn (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:100:31)
at runScriptViaChildProcessSpawn (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:189:23)
at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:132:16)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:115:20
at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:787:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:749:13)

Help please…

That usually means it can’t execute some file or command. Somewhere in the full message it should say which command as well.

kuzon@kuzon-Lenovo-Z580:/media/kuzon/FAVORITES/git_clones/ionicApp$ ionic platform add android
Updated the hooks directory to have execute permissions
running cordova platform add android
Running command: /media/kuzon/FAVORITES/git_clones/ionicApp/hooks/before_platform_add/init_directories.js /media/kuzon/FAVORITES/git_clones/ionicApp
Error: spawn EACCES
at exports._errnoException (util.js:746:11)
at ChildProcess.spawn (child_process.js:1162:11)
at Object.exports.spawn (child_process.js:995:9)
at Object.exports.spawn (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:100:31)
at runScriptViaChildProcessSpawn (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:189:23)
at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:132:16)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:115:20
at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:787:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:749:13)

@encodedmirko check this

maybe you created the project in a sudo bash instance and now you are working in a non-root bash.
So you do not have the permissions to create/remove files.

change file permission or execute the commands as root.

@bengtler
when i’m executing command as root it’s showing

/usr/bin/env: node: No such file or directory

are you doing this?:
sudo ionic platfom add android

node should be installed globally

It’s giving same error when i use sudo as root user and normal user

okay then check the ownership of the files and folders in your project if you as user has the correct permissions.

how to check the ownership of files

run ls -l in a terminal in the project directory.

r stands for read w for write x for execute and after that you can see the owner of the files

@bengtler some have read and write permissions,some have drwx

drwx------ 1 kuzon kuzon 4096 Jun 22 19:02 resources
drwx------ 1 kuzon kuzon 0 Jun 22 11:42 scss
drwx------ 1 kuzon kuzon 4096 Jun 22 11:42 www
drwx------ 1 kuzon kuzon 0 Jun 22 22:28 platforms
drwx------ 1 kuzon kuzon 0 Jun 22 19:03 plugins
drwx------ 1 kuzon kuzon 4096 Jun 22 22:31 hooks

could you do this also in the hooks, platform and plugins folder?

every thing has drwx permissions

Alright, would you be able to tell me what version of the ionic-cli you have?

ionic --version

If you have a version of 1.5+, you can try to do this before any platform add.

ionic hooks add

This will make sure the hooks have the right permissions to run

ionic version

1.4.0-beta.7

I’ve updated ionic to 1.5.5, @nicraboy @mhartington , please have a look at this

root@kuzon-Lenovo-Z580:/media/kuzon/FAVORITES/git_current/ionicApp# ionic hooks add
Adding in default Ionic Cordova hooks
Added default Ionic Cordova hooks
root@kuzon-Lenovo-Z580:/media/kuzon/FAVORITES/git_current/ionicApp# ionic platform add android
Updated the hooks directory to have execute permissions
Downloading Default Ionic Resources
Downloading: https://github.com/driftyco/ionic-default-resources/archive/master.zip
[=============================] 100% 0.0s
Done adding default Ionic resources
Adding icons for platform: android
Running command: /media/kuzon/FAVORITES/git_current/ionicApp/hooks/before_platform_add/init_directories.js /media/kuzon/FAVORITES/git_current/ionicApp
Error: spawn EACCES
at exports._errnoException (util.js:746:11)
at ChildProcess.spawn (child_process.js:1162:11)
at Object.exports.spawn (child_process.js:995:9)
at Object.exports.spawn (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:103:31)
at runScriptViaChildProcessSpawn (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:189:23)
at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:132:16)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:115:20
at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:787:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:749:13)

I see you’re trying to do this from the root user account. The root account is different than assigning privilege to an account via sudo.

You need to install NodeJS, Apache Cordova, and Android via another user account with sudo and then try to create projects using that same user account (without sudo). Otherwise your PATH and probably a lot of other stuff is going to continue getting in the way.

Also, I think you’re using Ubuntu Linux. Have you tried using this script?:

https://blog.nraboy.com/2014/09/install-android-cordova-ionic-framework-ubuntu/

Regards,

@nicraboy
@mhartington

same errors occur when i use ionic platform add android with sudo,normally and root user

How did you install everything though? What account and did you use sudo?