How do I make Browserify work with Puppeteer?

  • Thread starter Darkmisc
  • Start date
  • Tags
    Visual
  • #1
Darkmisc
204
27
TL;DR Summary
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:

fs message:
Error: Can't walk dependency graph: ENOENT: no such file or directory, lstat 'C:\Users\*****\Downloads\scraperpuppeteer\fs'

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.

dependencies:
  "dependencies": {
    "fs": "^0.0.1-security",
    "puppeteer": "^22.5.0"
  }


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:

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'

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


Thanks
 
Technology news on Phys.org
  • #2
Darkmisc said:
fs message:
Error: Can't walk dependency graph: ENOENT: no such file or directory, lstat 'C:\Users\*****\Downloads\scraperpuppeteer\fs'

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.
 
  • Like
Likes Darkmisc

Similar threads

  • Programming and Computer Science
Replies
2
Views
315
  • Programming and Computer Science
Replies
1
Views
696
  • Programming and Computer Science
Replies
2
Views
1K
Replies
3
Views
1K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
1
Views
5K
  • Programming and Computer Science
Replies
1
Views
3K
Replies
2
Views
3K
  • Programming and Computer Science
Replies
5
Views
5K
Back
Top