amazon-kindle-bulk-downloader: bun install error [ERR_REQUIRE_ESM]: Must use import to load ES Module

bun install throws an error:

bun install v1.2.2 (c1708ea6)
  đźšš pnpm... internal/modules/cjs/loader.js:1025
  throw new ERR_REQUIRE_ESM(filename);
  ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/rsholmes/Downloads/amazon-kindle-bulk-downloader-main/node_modules/puppeteer/install.mjs
    at Object.Module._extensions..mjs (internal/modules/cjs/loader.js:1025:9)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'ERR_REQUIRE_ESM'
}

error: postinstall script from "puppeteer" exited with 1

Using Linux Mint 21.3.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (4 by maintainers)

Most upvoted comments

Ah, I see, bun is a JavaScript runtime, npm is the package manager, and nodejs is . . . also a JavaScript runtime? Okay I’m still confused but I’m gonna move on. Here’s my versions and their sources:

keithzg@district:~$ which bun && bun --version
/home/keithzg/bin/bun
1.2.3
keithzg@district:~$ which nodejs && nodejs --version
/usr/bin/nodejs
v18.19.1
keithzg@district:~$ which npm && npm --version
/home/keithzg/.nvm/versions/node/v12.4.0/bin/npm
6.9.0
keithzg@district:~$ which node && node --version
/home/keithzg/.nvm/versions/node/v12.4.0/bin/node
v12.4.0

So I have nodejs in my path which is pointing to the apt package here in the latest Ubuntu LTS, but also a much older node installed via the Node Version Manager from clearly some monkeying around trying to compile some other NodeJS project, and with it a similarly old npm version. That sure sounds like a likely culprit! I should probably just wipe all that and try to go back to stable and automatically-upgraded distro packages but I’ll try first using that setup to use the latest stable NodeJS stack. Choosing what to install based on the output of nvm ls-remote --lts, which seems to align with a quick check of https://nodejs.org/, I end up with

v22.14.0 (npm v10.9.2)

And yup, you guessed it, bun puppeteer browsers install chrome worked fine after that. In fact, fully uninstalling my local nvm and reverting to purely distro apt packages (other than for bun, which does not appear to have one), aka node version v18.19.1 and npm version 9.2.0, also worked.

I’m using Kubuntu 24.04, and I see that Linux Mint 21.3 is based on Ubuntu 22.04. The versions in the 22.04 repo are node at 12.22.9 and npm at 8.5.1. I wasn’t easily able to replicate that because installing that version via NVM got me npm v6.14.15 by default, and upgrading it to the latest supported for that got me to npm v10.2.3, but in fact puppeteer commands failed with the same unexpected token error as above.

I worked back through NodeJS versions using NVM and I can (to the degree that my own questionable setup and poor understanding of the NodeJS ecosystem can be relied upon) confirm that the cutoff appears to be NodeJS v16, because both v16.20.2 (the latest LTS release of v16) and v16.13.0 (the oldest listed LTS of v16) work (even with old npm 8.1.0), but v14.21.3 (the latest LTS release of v14) does not work.

Took a brief look and Debian stable (“Bookworm”) is at NodeJS 18.19.0, with oldstable (“Bullseye”) at 12.22.12.

Or to sum it all up:

  • It looks like this project requires at least NodeJS version 16
  • It makes sense then that @rsholmes couldn’t run it out of the box on Linux Mint’s oldstable, and that should then be expected by any Ubuntu or Debian users still using the previous stable versions of their distro rather than the latest stable,
  • but anyone running Debian 12, Ubuntu 24.04, or Linux Mint 22.x (or higher) should be fine