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.

Import.meta error in vite 3.1.3

See original GitHub issue

Describe the bug

There appears to be a bug in vite 3.1.3: when using vite with react and typescript (using a package called vite-plugin-ssr) I get errors beginning with: [vite] warning: "import.meta" is not available in the configured target environment ("ES2017") and will be empty

If I change the version to vite 3.0.9, the error goes away. The issue is with the vite version rather than the vite-plugin-ssr package, as I understood it. Here is a reproduction: .

tsconfig has"module": "ES2020"and:

"ts-node": {
    "transpileOnly": true,
    "compilerOptions": {
      "module": "CommonJS"
    }
  }

Reproduction

https://stackblitz.com/edit/github-c4bkhn

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 3.16 GB / 15.73 GB
  Binaries:
    Node: 16.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (105.0.1343.42)
    Internet Explorer: 11.0.19041.1566

Used Package Manager

yarn

Logs

No response

Validations

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
htmnkcommented, Sep 21, 2022

https://github.com/vitejs/vite/issues/10167 might be related, similiar import.meta issues went away for me after setting esbuild.target to 'esnext' as a workaround.

0reactions
sapphi-redcommented, Sep 21, 2022

Yeah, it’s happening by the same cause with https://github.com/vitejs/vite/issues/10167. Closing to keep the discussion in a single place.

Read more comments on GitHub >

github_iconTop Results From Across the Web

import.meta undefined in components (Vite/Vue3)
i am trying to access the import.meta.env Variable 'APP_SOCKET_URL' in my component but it says Uncaught TypeError: import_meta.env is ...
Read more >
Vite 3.0 is out!
Vite is now using the new VitePress default theme, with a stunning dark mode between other features. ... import.meta.glob support was rewritten.
Read more >
vite js require is not defined | The AI Search Engine You Control
lib/Carousel/assets/${name}`, import.meta.url).href } return { carouselData, ... Datatable does not work in Laravel 9 & Vite; Error jQuery is not defined.
Read more >
TS1343: The 'import.meta' meta-property is only allowed when ...
I keep on getting this error when I try to build my project into esm and cjs. this is what my package.json looks...
Read more >
Using environment variables in SvelteKit (and Vite)
You can read more about Vite's import.meta.env here ... svelte-kit build with the following error: [rollup-plugin-dynamic-import-variables] ...
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