Node.js Google Drive Client – Error downloading file: is not a function

I am using the Node.js Google Drive client trying to download certain files from a gdrive. When using the example provided in their GitHub I get a Uncaught (in promise) TypeError: is not a function error. The file is still created locally, but it’s just an empty file from createWriteStream().

When I log the res variable I get: ReadableStream {locked: false}.

I’m pretty new to streams so this is quite a bit over my head.

Here is my code. You’ll notice it’s almost exactly what the example they provide looks like.

syncFileFromDrive(fileId, filePath) {
        filePath.replace(userDataPath, '');
        filePath = `${userDataPath}/${filePath}`;
        filePath.replaceAll('//', '/');`Sync file from drive: Syncing file to path: ${filePath}`);`Sync file from drive: File id: ${fileId}`)

        const dest = fs.createWriteStream(filePath);
        let progress = 0;{fileId, alt: 'media'}, {responseType: 'stream'}).then(res => {
                .on('end', () => {
                    console.log('Done downloading file.');
                .on('error', err => {
                    console.error('Error downloading file.');
                .on('data', d => {
                    progress += d.length;
                    if (process.stdout.isTTY) {
                        process.stdout.write(`Downloaded ${progress} bytes`);

96 thoughts on “Node.js Google Drive Client – Error downloading file: is not a function”

Leave a Comment