iisnode not recognizing gradle when executing cordova build command

21 Views Asked by At

I have this a ps1 script where I have yarn running cordova build command with arguments. If I run it through cmd, it builds the APK with no problems, but if I try running it with child-process spawn through my express app with iisnode, it doesn't run all the command.

shell script: $yrn = "yarn run cordova $action android --keystore='$keystore'";

express script:

    const child = spawn(`${path.join(__dirname, './goMobile2023/mobal/node_modules/yarn/bin/')}yarn p ${keystorePath}`, {
        shell: true,
        cwd: path.join(__dirname, './goMobile2023/mobal/'),
        detached: true, 
        stdio: [ 'inherit', fs.openSync('./out.log', 'a'), fs.openSync('./err.log', 'a') ],
    });

At first, iisnode was lacking permissions, so I granted all the permissions needed to IIS_IUSRS, but it still doesn't work.

The err.log logs this:

$ C:\APKBuilder\server\goMobile2023\mobal\node_modules\.bin\cordova build android --keystore=projects/mobileAssistencia/mobileAssistencia.goMobile.keystore

CHCP plugin after prepare hook:
    
    config-file preference is not set.
    
ANDROID_HOME=C:\Android\sdk

    JAVA_HOME=C:\Program Files\java\jdk1.8.0_131

Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

If I try to run cordova build instead of the script, it returns this:

Error: Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle 
in your path, or install Android Studio

It looks like iisnode is not being able to recognize gradle from path. How can I fix it?

0

There are 0 best solutions below