Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.4.0-beta.2] import.meta.env does not typecheck on linux #4028

IanVS opened this issue Jun 29, 2021 · 1 comment

[2.4.0-beta.2] import.meta.env does not typecheck on linux #4028

IanVS opened this issue Jun 29, 2021 · 1 comment


Copy link

IanVS commented Jun 29, 2021

Describe the bug

#4003 moved the definition of ImportMeta to a separate file and added a triple-slash directive to reference it. This works fine on case-insensitive operating systems, but not on linux. This seems to be because typescript converts the path to a lowercase string, vite/types/importmeta. This is not resolved on linux, and expressions like import.meta.env will throw a typescript error.

On mac, when I run npx tsc --traceResolution I get:

======== Type reference directive 'vite/types/importmeta' was successfully resolved to '/<absprojectpath>/node_modules/vite/types/importmeta.d.ts' with Package ID 'vite/types/importmeta.d.ts@2.4.0-beta.2', primary: false. ========

On Linux, my coworker sees:

======== Type reference directive 'vite/types/importmeta' was not resolved. ========

I think this is probably a typescript bug, but as a workaround I think it should be possible to rename the files to all-lowercase.


I'm not really sure how to show a reproduction of this problem...

System Info

Works on:

    OS: macOS 11.4
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 352.24 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
    Node: 14.16.1 - ~/.nvm/versions/node/v14.16.1/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v14.16.1/bin/yarn
    npm: 7.19.0 - ~/.nvm/versions/node/v14.16.1/bin/npm
    Brave Browser:
    Firefox: 88.0.1
    Safari: 14.1.1
    vite: ^2.4.0-beta.2 => 2.4.0-beta.2

I don't have a linux box to run the command on.

### Used Package Manager


### Logs

_No response_

### Validations

- [X] Follow our [Code of Conduct](
- [X] Read the [Contributing Guidelines](
- [X] Read the [docs](
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] 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 instead.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion]( or join our [Discord Chat Server](
IanVS added a commit to IanVS/vite that referenced this issue Jun 29, 2021
IanVS added a commit to IanVS/vite that referenced this issue Jun 29, 2021
IanVS added a commit to IanVS/vite that referenced this issue Jun 29, 2021
Copy link

This issue has been locked since it has been closed for more than 14 days.

If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 15, 2021
aleclarson pushed a commit to aleclarson/vite that referenced this issue Nov 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

1 participant