I am trying to use the Google Earth Engine API to generate images and upload to Google cloud storage via Node.js. I followed the GEE guide to authenticate a Google Cloud project server side. I am successfully authenticating and initializing GEE, but cannot get images to upload to my Google cloud Storage bucket.

Here is what I have so far.

// Require client library and private key.
var ee = require('@google/earthengine');
var privateKey = require('./.private-key.json');

// Initialize client library and run analysis.
var runAnalysis = function() {
  ee.initialize(null, null, function() {
    var landsat = new ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_123032_20140515')
        .select(['B4', 'B3', 'B2']);

    landsat.getMap({min: 0, max: 1000}, function(map) {

    var url = landsat
        .visualize({bands:['B4','B3','B2'], gamma: 1.5})
        .getThumbURL({dimensions:'1024x1024', format: 'jpg'});


    // Create a geometry representing an export region.
    var geometry = new ee.Geometry.Rectangle([116.2621, 39.8412, 116.4849, 40.01236]);

    var task = ee.batch.Export.image.toCloudStorage({
        image: landsat,
        description: 'imageToCloudExample',
        bucket: 'my-bucket',
        fileNamePrefix: 'exampleExport',
        scale: 30,
        region: JSON.stringify( geometry.toGeoJSON())
  task.start(function () {
    console.log('Started task #' + task.id);
    }, function (error) {
      console.log('Error: ' + error);

  }, function(e) {
    console.error('Initialization error: ' + e);

// Authenticate using a service account.
ee.data.authenticateViaPrivateKey(privateKey, runAnalysis, function(e) {
  console.error('Authentication error: ' + e);

When I run this, I see a task id printed to my console, but nothing is making it to my cloud storage.

Started task #3e174fb0-0107-47f6-b4d6-3ac5ef2247a0

Does anyone know the proper way to export from GEE to cloud storage using node.js?

  • Can you see the task if you go to the Code Editor? Missing, failed, completed? Commented Jun 2, 2022 at 7:47
  • I couldn't actually see the tasks in the Code Editor, which was surprising to me because I thought it would show all the tasks attached to my account. I could see them when I called ee.data.listOperations() when debugging. See my answer below.
    – Andre Otte
    Commented Jun 7, 2022 at 0:46

1 Answer 1


The issue ended up being an authorization error being thrown on the Google Cloud Storage end. Unfortunately, the error wasn't bubbling up through the callback function. I ended up discovering it by calling ee.data.listOperations() while debugging and seeing that the tasks failed to complete and the error thrown. See this question and answer for more explanation on ee.data.listOperations().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.