Works in dev, but not on a production build
See original GitHub issueDescribe the bug
So, I upgraded my project from Vite v2.9.15
to v3.1.8
, after which I started getting build warnings and issues.
Reproduction
https://stackblitz.com/edit/vitejs-vite-retclp?file=main.js
Steps to reproduce
Run:
yarn
yarn build
yarn preview # optional
Open https://piped.kavin.rocks/watch?v=CKo-jOp6twg
System Info
System:
OS: Linux 6.0 undefined
CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
Memory: 6.16 GB / 13.53 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 16.16.0 - /usr/bin/node
Yarn: 1.22.17 - /usr/bin/yarn
npm: 8.19.2 - /usr/bin/npm
Browsers:
Brave Browser: 106.1.44.112
Chromium: 106.0.5249.119
Firefox: 106.0
Used Package Manager
yarn
Logs
Browser:
Uncaught (in promise) TypeError: Failed to resolve module specifier "emitter". Relative references must start with either "/", "./", or "../".
Vite build:
node_modules/stream/index.js'emitter' is imported by emitter?commonjs-external, but could not be resolved – treating it as an external dependency
The symptoms are quite similar to #6586
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
App works in development but not in production (doesn't build)
I have a react app that runs fine in development (npm start) and doesn't throw any errors. But when I try to build...
Read more >Webpack works perfectly for development, but production ...
I am having a hard time explaining why the development build works but the production build does not even with identical config.
Read more >Production build fails but dev works fine #930 - GitHub
I've spotted production build fail with error. Uncaught ReferenceError: y is not defined (See screenshot below)
Read more >Optimizing Performance - React
If you're benchmarking or experiencing performance problems in your React apps, make sure you're testing with the minified production build. By default, React ......
Read more >Building for Production - Vite
During dev, simply navigate or link to /nested/ - it works as expected, just like for a normal static file server. During build,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, I’ve added a StackBlitz for reproduction.
Hmmm, not sure what’s going on here! It started appearing on my project when I upgraded to v3. I did some digging and found something related to
emitter
: https://github.com/juliangruber/stream/pull/6! Would this still be a vite issue, considering that it only occurs in prod builds?