Uncaught ReferenceError: __DEFINES__ is not defined

See original GitHub issue

I just clone the template and run ‘pnpm i’ and ‘pnpm dev’, and load the extension to chrome, but I get this error

Uncaught ReferenceError: __DEFINES__ is not defined

for the backgound script. This error introduced from this file https://github.com/vitejs/vite/blob/fa30f76e49de0ca8abd96c1fd866da0512ed29b9/packages/vite/src/client/env.ts I try to use yarn and firefox, same error.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
tmkxcommented, Aug 25, 2021

It’s because that the background script imports /@vite/client since this PR, and then Vite will pre-bundle the deps, but, pre-bundling will not replace magic constants such as __DEFINES__.

You can try this workaround:

 optimizeDeps: {
   include: ['vue', '@vueuse/core'],
-   exclude: ['vue-demi'],
+   exclude: ['vue-demi', '@vite/client', '@vite/env'],
 },

and then delete Vite’s cache dir node_modules/.vite

This will be solved in https://github.com/vitejs/vite/pull/4716

1reaction
iceshucommented, Jul 31, 2022

I have the some issue with vite v2.9.14 image the dev env is ok but the product build is not work. image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught ReferenceError: define is not defined typescript
This loads RequireJS from 'scripts/require.js' and then tells it to load the script at 'scripts/main.js' to start off the loading process (you' ...
Read more >
Getting error "ReferenceError: define is not defined" #1706
In webstorm IDE, I am getting an error when I am using wallaby with requirejs: "ReferenceError: define is not defined".
Read more >
"define" is not defined in .js - Coding Help - Glitch Support
I'm getting the error ““define” is not defined” in my .js code, but only in the glitch editor, it seems to work fine...
Read more >
Uncaught ReferenceError: define is not defined
Basically $ is an alias of jQuery() so when you try to call/access it before declaring the function, it will endup throwing this...
Read more >
ReferenceError: define is not defined at Script Document
i got this error after i upload my main.js which compiled by my typescript files, my tsconfig.json below:.
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