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.

Property 'env' does not exist on type 'ImportMeta' in 3.0.0

See original GitHub issue

Describe the bug

In vite 3.0.0 it still exists, even if it was previously closed.

Can be recreated using react-ts template. Try to use env variable via import.meta.env, TS will give you an error Property 'env' does not exist on type 'ImportMeta'.

According to the docs it should work: https://vitejs.dev/guide/env-and-mode.html

Reproduction

yarn create vite my-app --template react-ts

System Info

System:
    OS: macOS 11.6
    CPU: (8) arm64 Apple M1
    Memory: 128.70 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    Yarn: 1.22.15 - ~/.nvm/versions/node/v16.14.2/bin/yarn
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
  Browsers:
    Chrome: 103.0.5060.134
    Firefox: 103.0.1
    Safari: 15.4
    Safari Technology Preview: 15.4

Used Package Manager

yarn

Logs

No response

Validations

Issue Analytics

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

github_iconTop GitHub Comments

8reactions
iulocommented, Aug 5, 2022

same issue, add import 'vite/client' to a shared .d.ts file in project fix it.

3reactions
cqgsmcommented, Sep 9, 2022

image tsconfig.config.json

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript Types for import.meta.env - vue.js - Stack Overflow
I've tried the following but does not work. declare global { namespace NodeJS { interface ImportMeta { GITHUB_AUTH_TOKEN: string; NODE_ENV: ' ...
Read more >
Features | Vite
Vite supports importing .ts files out of the box. Vite only performs transpilation on .ts files and does NOT perform type checking. It...
Read more >
import-meta-resolve - npm
Start using import-meta-resolve in your project by running `npm i import-meta-resolve`. There are 87 other projects in the npm registry ...
Read more >
Vite-plugin-glob - npm.io
There are quite some scenarios that import.meta.glob wasn't considered when it's been implemented at the beginning. So we received quite a few PRs...
Read more >
ImportMeta | Runtime APIs - Deno
Deno provides extra properties on `import.meta`. These are included here to ensure that these are still available when using the Deno namespace in ......
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