-
Notifications
You must be signed in to change notification settings - Fork 584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] pnpm build failed #269
Comments
someone have solution for this error? |
@morethanwords @ezrawic4j I've found that some of the chunks have no And when I fixed the file by adding conditions - the build has been successful So maybe the problem with the chunk generation or something else |
I see, thanks. As I understand it's your official workaround for this bug. Can you write an issue to the specific package (rollup/vite) to fix the problem from the root? |
Compilation error reported: PS \tweb> vite build
has built solid true
vite v4.3.1 building for production...
✓ 1111 modules transformed.
rendering chunks (30)...The emitted file "lang-49055ff2.js" overwrites a previously emitted file of the same name.
The emitted file "pluralPolyfill-61f068d6.js" overwrites a previously emitted file of the same name.
The emitted file "countries-5301fc59.js" overwrites a previously emitted file of the same name.
The emitted file "langSign-66e8939d.js" overwrites a previously emitted file of the same name.
The emitted file "lang-49055ff2.js.map" overwrites a previously emitted file of the same name.
The emitted file "pluralPolyfill-61f068d6.js.map" overwrites a previously emitted file of the same name.
The emitted file "langSign-66e8939d.js.map" overwrites a previously emitted file of the same name.
[vite:build-import-analysis] Cannot read properties of undefined (reading 'forEach')
✓ built in 48.32s
error during build:
TypeError: Cannot read properties of undefined (reading 'forEach')
at addDeps (/tweb/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-24daf00c.js:45215:55)
at Object.generateBundle (/tweb/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-24daf00c.js:45239:33)
at /tweb/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:24412:40 Solution: Find the error line in the dep-24daf00c.js file and modify it: Aboriginal: chunk.imports.forEach(addDeps);
// Ensure that the css imported by current chunk is loaded after the dependencies.
// So the style of current chunk won't be overwritten unexpectedly.
chunk.viteMetadata.importedCss.forEach((file) => {
deps.add(file);
}); Modified: if (chunk.imports){
chunk.imports.forEach(addDeps);
}
// Ensure that the css imported by current chunk is loaded after the dependencies.
// So the style of current chunk won't be overwritten unexpectedly.
if (chunk.viteMetadata && chunk.viteMetadata.importedCss){
chunk.viteMetadata.importedCss.forEach((file) => {
deps.add(file);
});
} Finally, run the 'vite build' again and compile it successfully. https:/morethanwords/tweb/issues/269#issuecomment-1825082899 |
Hello @morethanwords, I am having this issue when trying to migrate quite a huge frontend project from CRA to Vite and this is the only things stopping me currently Do you know if they will approve and let your fix into production? |
Not sure yet, you could also ask them here vitejs/vite#15469, maybe they will change the priority from minor. |
Thanks for answering, I have found a solution on my end I used In my
|
✓ 781 modules transformed.
rendering chunks (28)...The emitted file "lang-5a385cdb.js" overwrites a previously emitted file of the same name.
The emitted file "langSign-66e8939d.js" overwrites a previously emitted file of the same name.
The emitted file "pluralPolyfill-61f068d6.js" overwrites a previously emitted file of the same name.
The emitted file "countries-5301fc59.js" overwrites a previously emitted file of the same name.
The emitted file "lang-5a385cdb.js.map" overwrites a previously emitted file of the same name.
The emitted file "langSign-66e8939d.js.map" overwrites a previously emitted file of the same name.
The emitted file "pluralPolyfill-61f068d6.js.map" overwrites a previously emitted file of the same name.
The emitted file "countries-5301fc59.js.map" overwrites a previously emitted file of the same name.
[vite:build-import-analysis] Cannot read properties of undefined (reading 'forEach')
✓ built in 39.95s
error during build:
TypeError: Cannot read properties of undefined (reading 'forEach')
at addDeps (file:///home/tweb/node_modules/.pnpm/vite@4.3.1_@types[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-24daf00c.js:45215:55)
at Object.generateBundle (file:///home/tweb/node_modules/.pnpm/vite@4.3.1_@types[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-24daf00c.js:45236:33)
at file:///home/tweb/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:24412:40
ELIFECYCLE Command failed with exit code 1.
The text was updated successfully, but these errors were encountered: