jprichardson / node-fs-extra

Node.js: extra methods for the fs object like copy(), remove(), mkdirs()
MIT License
9.44k stars 776 forks source link

process is not defined #958

Closed paddotk closed 2 years ago

paddotk commented 2 years ago

I get an error 'process is not defined' when I try to import this lib. I'm using this in NodeJS.

Full error stack:

Uncaught ReferenceError: process is not defined
    at node_modules/graceful-fs/polyfills.js (polyfills.js:3:15)
    at __require (chunk-IGMYUX52.js?v=f6b96a9a:40:50)
    at node_modules/graceful-fs/graceful-fs.js (graceful-fs.js:2:17)
    at __require (chunk-IGMYUX52.js?v=f6b96a9a:40:50)
    at node_modules/fs-extra/lib/fs/index.js (index.js:5:12)
    at __require (chunk-IGMYUX52.js?v=f6b96a9a:40:50)
    at node_modules/fs-extra/lib/index.js (index.js:5:6)
    at __require (chunk-IGMYUX52.js?v=f6b96a9a:40:50)
    at dep:fs-extra:1:16
RyanZim commented 2 years ago

Looks like you're using some kind of code bundling?

paddotk commented 2 years ago

@RyanZim Yes, I'm using Webpack in my project.

RyanZim commented 2 years ago

Webpack is probably bundling your code for browser, and not allowing process to be defined. Webpack is primarily intended for browser code; Node.js code isn't generally bundled.