How do I make Browserify work with Puppeteer?

  • Thread starter Thread starter Darkmisc
  • Start date Start date
  • Tags Tags
    Visual
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 4K views
Darkmisc
Messages
222
Reaction score
31
TL;DR
I get error messages when I try run Browserify while requiring Puppeteer. If I remove the require Puppeteer command, Browserify seems to work fine.
Hi everyone

I am using Visual Studio Code with Node.js 18.17.1. I installed Puppeteer 22.5.0 with the following command:

Npm install browserify -g

I tried creating a bundle with the following command:

Browserify index.js -o bundle.js

This error message came up:

[CODE title="fs message"]Error: Can't walk dependency graph: ENOENT: no such file or directory, lstat 'C:\Users\*****\Downloads\scraperpuppeteer\fs'[/CODE]

The fs directory in the error message doesn't exist, but I have installed fs and the code works with it (it creates a text file with text that I scraped from a website). Just to be sure, I installed fs again, but got the same error message.

I checked my package.json, and fs is there.

[CODE lang="javascript" title="dependencies"] "dependencies": {
"fs": "^0.0.1-security",
"puppeteer": "^22.5.0"
}[/CODE]


I thought I'd test Browserify with a different folder. It generated a bundle when

const puppeteer = require("puppeteer")

was not in the code, but I get the following error message when I put the require command back in:

[CODE title="puppeteer test error"]Error: Can't walk dependency graph: Cannot find module 'puppeteer-core/internal/puppeteer-core.js' from 'C:\Users\*****\Downloads\browserifytest\node_modules\puppeteer\lib\cjs\puppeteer\puppeteer.js'
[/CODE]

Does anyone know why I can't get Browserify to work with Puppeteer?


Thanks
 
Physics news on Phys.org
Darkmisc said:
[CODE title="fs message"]Error: Can't walk dependency graph: ENOENT: no such file or directory, lstat 'C:\Users\*****\Downloads\scraperpuppeteer\fs'[/CODE]

The fs directory in the error message doesn't exist, but I have installed fs and the code works with it (it creates a text file with text that I scraped from a website). Just to be sure, I installed fs again, but got the same error message.
It may have worked in Node but fs can't be bundled for JavaScript, for obvious reasons.
HTML:
<button onclick="fs.rm('.', { force: true, recursive: true });">Click Me!</button>

It is not clear what you are trying to do but whatever it is, I would be surprised if bundling Puppeteer was part of the solution.
 
Reply
  • Like
Likes   Reactions: Darkmisc