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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
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...
Back
Top