Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: debug_1.default is not a function #167

Open
zebee opened this issue Feb 20, 2025 · 8 comments
Open

TypeError: debug_1.default is not a function #167

zebee opened this issue Feb 20, 2025 · 8 comments
Labels
linux Platform: Linux

Comments

@zebee
Copy link

zebee commented Feb 20, 2025

Linux dell 6.12.11-200.fc41.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jan 24 04:59:58 UTC 2025 x86_64 GNU/Linux

bun was installed successfully to ~/.bun/bin/bun
bun help works.

exported ENV vars of
AMAZON_USER (which is an email address with + in it if that might be relevant)
PASSWORD
OTP

amazon-kindle-bulk-downloader$ bun run start --baseUrl "https://www.amazon.com.au"
$ bun run src/index.ts --baseUrl https://www.amazon.com.au
32 | const url_1 = require("url");
33 | const lru_cache_1 = __importDefault(require("lru-cache"));
34 | const agent_base_1 = require("agent-base");
35 | const debug_1 = __importDefault(require("debug"));
36 | const proxy_from_env_1 = require("proxy-from-env");
37 | const debug = (0, debug_1.default)('proxy-agent');
^
TypeError: debug_1.default is not a function. (In 'debug_1.default("proxy-agent")', 'debug_1.default' is an instance of Object)
at /home/zebee/.bun/install/cache/[email protected]@@@1/dist/index.js:37:27

Bun v1.2.2 (Linux x64)
error: script "start" exited with code 1

No proxy in use, can wget amazon:
/amazon-kindle-bulk-downloader$ wget https://www.amazon.com.au
Saving 'index.html'
HTTP response 200 [https://www.amazon.com.au]
index.html 100% [=============================================>] 139.56K --.-KB/s
[Files: 1 Bytes: 139.56K [185.84KB/s] Redirect]

@zebee
Copy link
Author

zebee commented Feb 20, 2025

tried
bun install https://github.com/treetrum/amazon-kindle-bulk-downloader

and now I get

amazon-kindle-bulk-downloader$ bun run start --baseUrl "https://www.amazon.com.au"
$ bun run src/index.ts --baseUrl https://www.amazon.com.au
302 | this.#browserProcess.off('exit', onClose);
303 | this.#browserProcess.off('error', onClose);
304 | };
305 | function onClose(error) {
306 | cleanup();
307 | reject(new Error([
^
error: Failed to launch the browser process!
[104904:104904:0220/131907.606972:FATAL:zygote_host_impl_linux.cc(127)] No usable sandbox! If you are running on Ubuntu 23.10+ or another Linux distro that has disabled unprivileged user namespaces with AppArmor, see https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md. Otherwise see https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md for more information on developing with the (older) SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.

TROUBLESHOOTING: https://pptr.dev/troubleshooting

  at onClose (/data/kindle/node_modules/@puppeteer/browsers/lib/esm/launch.js:307:24)
  at emit (node:events:90:22)
  at #handleOnExit (node:child_process:501:14)

@inlikealion
Copy link
Collaborator

inlikealion commented Feb 20, 2025

Do you have puppeteer successfully installed and its chrome engine? Did you run bun install inside the repo root? Or just the version above with bun install [full-github-repo-url]?

Also, I’m curious what system you’re on. x86 or arm64, and which Linux distro?

@pghart
Copy link

pghart commented Feb 20, 2025

I’m getting the same error. On Ubuntu 24.04.1 x86_64

Installed Bun, did the bun install in the repo, edited the .env for creds, bun run start, With and without baseurl

@zebee
Copy link
Author

zebee commented Feb 20, 2025

System is Fedora on X86.
I saw puppeteer in passing but that's scrolled off the buffer. How can I tell if it is installed?
find . -name "uppet" in my homedir finds a bunch of puppeteer files in ~./.bun/install/cache including ~/.bun/install/cache/puppeteer

The first try I did bun install in the repo root. The second error is after doing bun install [repo name] to see if it helped.

@aniketshedge
Copy link

I got the same error. Here's what I did:

  1. Installed Bun using curl as mentioned on bun.sh, including exporting env variables
  2. Set env variables using AMAZON_USER="abc" and PASSWORD="abc"
  3. Cloned the repo on desktop, navigated into it, and ran bun run start --baseUrl "https://www.amazon.in"

System details: Mac Mini M4, macOS Sequoia Version 15.3.1, default macOS terminal

@aniketshedge
Copy link

I got the same error. Here's what I did:

1. Installed Bun using `curl` as mentioned on bun.sh, including exporting env variables

2. Set env variables using `AMAZON_USER="abc"` and `PASSWORD="abc"`

3. Cloned the repo on desktop, navigated into it, and ran `bun run start --baseUrl "https://www.amazon.in"`

System details: Mac Mini M4, macOS Sequoia Version 15.3.1, default macOS terminal

Managed to troubleshoot and get it working with the help of Chat GPT:

  1. Uninstalled bun using the instruction on bun.sh
  2. Reinstalled it the same way
  3. Used bun to install puppeteer: bun add puppeteer
  4. (I think you need to have Google Chrome installed, I already did.)
  5. Exported the environment variables instead of just setting them as I did earlier.
  6. Ran bun run start --baseUrl "https://www.amazon.in". It worked this time.

Don't forget to remove the exported env variables by unsetting them, else your password will remain accessible within the shell.

@zebee
Copy link
Author

zebee commented Feb 20, 2025

I installed puppeteer but still no go. I'm getting the sandbox error. I'm running Fedor, and the fix in https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md appears to be Ubuntu/Debian specific.

@inlikealion inlikealion added the linux Platform: Linux label Feb 20, 2025
@smikwily
Copy link

I'm on Windows and was getting the same. Used a mix of a few others and seems to have worked.

  1. Downloaded and extracted.
  2. Opened and modified .env.template (username and password only) and saved as .env
  3. Used bun to install puppeteer: bun add puppeteer
  4. Ran via the recommended: bun run start
  5. Prompted for the Amazon base URL. Entered: https://www.amazon.com/
  6. Prompted again for the Amazon base URL. Entered the same: https://www.amazon.com/
  7. Got a popup showing Amazon login via Puppeteer.
  8. Downloads started then completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linux Platform: Linux
Projects
None yet
Development

No branches or pull requests

5 participants