1

I am trying to bundle the code below using browserify

const { ESLint } = require('eslint');
console.log(ESLint);

And when I include the generated bundle in a html file, I get this error.

Uncaught TypeError: require(...).pathToFileURL is not a function

When I checked the generated bundle I found that it contained require() function. Browserify should recursively replace all require() and combine them into one file, right? I am using Node.js version 14.15.1 and eslint version 8.13.0.

bundle.js

Is there something I've missed. Any help would be really appreciated. Thanks!

  • Could you maybe add a stack trace? Also, what version of ESLint? What version of Node.js? – GOTO 0 Apr 24 '22 at 19:55
  • @GOTO0 I have update the question. – Danish Khan Apr 26 '22 at 08:04
  • I have the same issue when using Webpack 5, "require('url').pathToFileURL is not a function". Haven't solved it yet, but it's because "node:url" exports the pathToFileURL function but the npm package "url" doesn't export it. – tornord May 08 '22 at 09:06
  • this could be a long shot, but are you running an ancient version of node? try upgrading it. – J'e Jun 16 '22 at 18:02

0 Answers0