How do I make Browserify work with Puppeteer?

  • Thread starter Thread starter Darkmisc
  • Start date Start date
  • Tags Tags
    Visual
AI Thread Summary
The discussion revolves around issues encountered while using Browserify with Puppeteer in a Node.js environment. The user reports an error when trying to create a bundle, specifically an "ENOENT" error indicating that a directory named 'fs' cannot be found, despite having the 'fs' module listed in their package.json. The user confirms that their code works for creating a text file, suggesting that the 'fs' module is functional in their setup. However, it is noted that 'fs' cannot be bundled for JavaScript due to its nature. Additionally, when testing Browserify without the Puppeteer require statement, a different error arises related to a missing module within Puppeteer. The discussion emphasizes that bundling Puppeteer may not be necessary or advisable for the user's goals, indicating potential misunderstandings about the use of Browserify with certain Node.js modules.
Darkmisc
Messages
222
Reaction score
31
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:

[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
 
Technology 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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top