question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Works in dev, but not on a production build

See original GitHub issue

Describe 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

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
FireMasterKcommented, Oct 20, 2022

Hi, I’ve added a StackBlitz for reproduction.

0reactions
FireMasterKcommented, Oct 25, 2022

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found