You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If this issue only occurs in one browser, which browser is a problem?
Chrome
Describe the Bug
after I run "npm run build", there is the error:
22:05:21 [ERROR] [vite] "stat" is not exported by "__vite-browser-external", imported by "node_modules/escalade/dist/index.mjs". file: /Users/qihui/personal/danieljia.work/node_modules/escalade/dist/index.mjs:2:18 1: import { dirname, resolve } from 'path'; 2: import { readdir, stat } from 'fs'; ^ 3: import { promisify } from 'util'; "stat" is not exported by "__vite-browser-external", imported by "node_modules/escalade/dist/index.mjs". Stack trace:
there are some warnings: 22:05:20 [WARN] [vite] [plugin:vite:resolve] Module "module" has been externalized for browser compatibility, imported by...
I can't reproduce the error with the link given. Is it working for you too? About the error, it's because you're importing a node-only module into some client-side components. Things like fs.stat from node:fs doesn't work in the browser.
same for me, the error is not reproducible when doing the commands, (i dont know if this is still happening to you) i had the same issue when doing the build command, with an astro auth dependency trying to import 'dirname'.
at build time vite treats the dependency as external and not as an internal dependency from node, so tries to import it as if it was some browser module or something like that.
chatgpt suggested, or explained to me that u have to specify vite to treat the dependency as a node module, so it can import it properly at build time
vite: {build: {rollupOptions: {external: ['node:path']// Mark 'node:path' as external}}}
and i can guess youll have to do that with every node module dependency giving you the same error
and that solve the issue, as to running npm build
Astro Info
If this issue only occurs in one browser, which browser is a problem?
Chrome
Describe the Bug
after I run "npm run build", there is the error:
22:05:21 [ERROR] [vite] "stat" is not exported by "__vite-browser-external", imported by "node_modules/escalade/dist/index.mjs". file: /Users/qihui/personal/danieljia.work/node_modules/escalade/dist/index.mjs:2:18 1: import { dirname, resolve } from 'path'; 2: import { readdir, stat } from 'fs'; ^ 3: import { promisify } from 'util'; "stat" is not exported by "__vite-browser-external", imported by "node_modules/escalade/dist/index.mjs". Stack trace:
there are some warnings:
22:05:20 [WARN] [vite] [plugin:vite:resolve] Module "module" has been externalized for browser compatibility, imported by...
What's the expected result?
no bug
Link to Minimal Reproducible Example
https://stackblitz.com/github/withastro/astro/tree/latest/examples/blog?file=README.md&on=stackblitz
Participation
The text was updated successfully, but these errors were encountered: