Import.meta error in vite 3.1.3
See original GitHub issueDescribe 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
- 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
- Reactions:1
- Comments:5 (1 by maintainers)
Top 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 >
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
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.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.