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.

Development mode is incorrect in vite dev

See original GitHub issue

Summary

In a browser accessing a Vite dev server, the value of isDevelopment() is false.

Therefore /_vercel/insights/script.js is requested, resulting in a 404 Not Found.

Reason

In a browser accessing a Vite dev server, the process is undefined.

https://github.com/vercel/analytics/blob/74c2474ebbb75c50a0009b067e25c56d5255c6a5/packages/web/src/utils.ts#L5-L10

Therefore isDevelopment() returns false.

Reproduction

Open the browser console to see what is logged in the client inside StackBlitz.

Values

In a browser accessing a Vite dev server:

SvelteKit Next.js
isBrowser() true true
isDevelopment() false * true
typeof process undefined * object
typeof process.env.NODE_ENV string string
process.env.NODE_ENV development development

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chriswdmrcommented, Dec 7, 2022

Awesome! Side note: we’re going to ship it as mode instead of __mode.

You can disable those log messages by providing the debug property with false if your mode is development.

Please see our documentation around the debug property

0reactions
chriswdmrcommented, Dec 12, 2022

Perfect, thanks for confirmation.

Closing as it’s resolved with v0.1.6

Documentation is already updated

Read more comments on GitHub >

github_iconTop Results From Across the Web

Development mode transpiles correctly while build doesn't.
This loads bip39 and works perfectly when running yarn dev(I did have to use some work arounds to get it running), when building...
Read more >
Troubleshooting - Vite
Vite cannot handle and does not support code that only runs on non-strict mode (sloppy mode). This is because Vite uses ESM and...
Read more >
Vue.js 3: run build vite with dev configuration for debugging
I modified the package.json definition for npm run build to change the associated command to "vite build --mode dev" but that didn't work...
Read more >
Asset Bundling (Vite) - The PHP Framework For Web Artisans
There are two ways you can run Vite. You may run the development server via the dev command, which is useful while developing...
Read more >
Configuring Vitest
Create vitest.config.ts , which will have the higher priority and will override the configuration from vite.config.ts; Pass --config ...
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