FredKSchott / rollup-plugin-polyfill-node

A modern Node.js polyfill for your Rollup bundle.
Other
176 stars 55 forks source link

Error: 'fileURLToPath' is not exported by polyfill-node.url.js #49

Open gjhltn opened 2 years ago

gjhltn commented 2 years ago

I'm using 0.9.0 and seeing this error when I bundle.

If I put nodePolyfills() first in my plug-ins array in config I get this error

[!] Error: 'fileURLToPath' is not exported by polyfill-node.url.js, imported by ../
../node_modules/vfile/lib/minurl.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
../../node_modules/vfile/lib/minurl.js (1:8)
1: export {fileURLToPath as urlToPath} from 'url'
           ^
2: export {isUrl} from './minurl.shared.js'
Error: 'fileURLToPath' is not exported by polyfill-node.url.js, imported by ../../n
ode_modules/vfile/lib/minurl.js

...

if I put it after node-resolve etc, I get an error that node shims aren't installed.

All this is accurate. fileURLToPath Is indeed not exported by that module. And yet I don't understand! 😀

what am I doing wrong?

gjhltn commented 2 years ago

Well, I'm not sure if this is the right fix, but doing

nodeResolve({browser: true }),

worked for me, fwiw

IgnacioRassol commented 2 years ago

Thanks, I ran into the same issue and this seemed to do the trick. In my case, I didn't even need to use rollup-plugin-polyfill-node after setting {browser: true }. Not sure why this works.