ARTICLE AD BOX
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.
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.
Explore related questions
See similar questions with these tags.

