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)
Ah, I see,
bunis a JavaScript runtime,npmis the package manager, andnodejsis . . . also a JavaScript runtime? Okay I’m still confused but I’m gonna move on. Here’s my versions and their sources:So I have
nodejsin my path which is pointing to the apt package here in the latest Ubuntu LTS, but also a much oldernodeinstalled via the Node Version Manager from clearly some monkeying around trying to compile some other NodeJS project, and with it a similarly oldnpmversion. 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 ofnvm ls-remote --lts, which seems to align with a quick check of https://nodejs.org/, I end up withAnd yup, you guessed it,
bun puppeteer browsers install chromeworked fine after that. In fact, fully uninstalling my localnvmand reverting to purely distro apt packages (other than for bun, which does not appear to have one), akanodeversionv18.19.1andnpmversion9.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
nodeat12.22.9andnpmat8.5.1. I wasn’t easily able to replicate that because installing that version via NVM got menpm v6.14.15by default, and upgrading it to the latest supported for that got me tonpm 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) andv16.13.0(the oldest listed LTS of v16) work (even with oldnpm 8.1.0), butv14.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: