Error: __dirname is not defined after deploying assets canister

after deploy assets canister, got below error from browser console: https://3hhuc-aqaaa-aaaah-aavra-cai.ic0.app/

index.961d7240.js:2495 Uncaught ReferenceError: __dirname is not defined
at index.961d7240.js:2495:29316
at index.961d7240.js:2495:29367

even rollback previous working code, still get the same error, please help

note: it works locally

Note a direct answer but, just in case helpful, __dirname was a NodeJS variable that has been deprecated in Node 18 (if I remember correctly). So did you bump your NodeJS version or any library and is maybe some polyfill at npm run build time not correctly applied anymore?

no, the same node v18.19.0, and no dependency changes

Maybe some code lead to loading the gzip-size library now and it was not the case before? But the issue is clear to me __dirname does not exist in the browser API. So I would be on a NodeJS polyfill not applied or something in that sort in build process. Hard to tell more, sorry.

1 Like

thanks, I am trying to drill down where it is. :disappointed:

1 Like

You found the solution?

no, I found where the issue it, the old module from commonjs, I tried vite-plugin-node-polyfills - npm, but no luck, so just disable it for now. Need to do more investigation.

1 Like