I am using NodeJs to try and import the following package into my sheet:

const { GoogleSpreadsheet } = require('google-spreadsheet');

I get the error: "Error [ERR_REQUIRE_ESM]: require() of ES Module [...] not supported."

From the error itself I gather this is something to do with how the package imports and may be because I am using node, however I am unsure.

I have attempted updating and reinstalling my packages and dependencies, aside from completely dooming my package file and needing to reinit there was no effect.

From reading other solutions they provide solutions however I do not feel like I understand what the error means and that is important to me.

TheProgrammerEthan's user avatar

1

The package google-spreadsheet is published as an ES Module. Therefor It cannot be imported using require(). It must be imported using import .

Change your import to

import { GoogleSpreadsheet } from 'google-spreadsheet';

Also update your package.json as

{ "type": "module" }

Please make sure you do the same for rest of the packages too. Read this for further clarification.

Shehan Lakshitha's user avatar

1 Comment

This is... not true? Node can require an ESM module just fine. It can also import from a CJS library. You just need to be on an up to date version of Node.

2026-01-17T06:00:41.62Z+00:00

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.