Getting Internal error encountered when running Google APP script using GoogleAPI npm library

I have a Google app script that takes a DOC ID as input and converts it into a PDF using the below code:

 var pdfFile = DriveApp.createFile(doc.getBlob().getAs('application/pdf'));

Now I am running the above-mentioned Google APP script from a node js server using googleapis npm library and I am executing in the below way


     try {
        const request = {
          scriptId: SCRIPT_ID,
          resource: {
            function: 'exportDocToPDFAndSaveToDrive', 
          },
          auth: client,
        };
        const response = await script.scripts.run(request);
        console.log(response.data);
      } catch (err) {
        console.log("Error in executing a google app's script", JSON.stringify(err));
      }

Now when running the the above code from a NODE JS Server I am getting the below error
[{"message": "Internal error encountered.","domain": "global", "reason": "backendError"}]}
I am performing authentication using a service account and I shared the script with the service account email.
I linked the Google App script and GCP project of that service account in Project settings section of Google Apps script.
What could be the reason for this issue and in API’s and Services of the GCP project I enabled Google App script API.
i am using below scopes during authorisation

  'https://www.googleapis.com/auth/drive',
  'https://www.googleapis.com/auth/drive.file',
  'https://www.googleapis.com/auth/spreadsheets',
  'https://www.googleapis.com/auth/documents',
  'https://www.googleapis.com/auth/documents.readonly',
  'https://www.googleapis.com/auth/drive.readonly',
  'https://www.googleapis.com/auth/script.external_request',

Please help me with above query