0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Property 'env' does not exist on type 'importMeta' 解決方法

Last updated at Posted at 2026-01-01

エラー内容

Screenshot 2026-01-01 at 20.09.35.png

解決方法

TypeScriptは import.meta.env の型を標準では持たないため、Viteが用意している ImportMetaEnv を明示的に拡張する必要があります。
環境変数の型を定義することで解決できます!

/// <reference types="vite/client" />

interface ImportMetaEnv {
  readonly VITE_API_URL: string;
  // ...ここに追加していく
}

interface ImportMeta {
  readonly env: ImportMetaEnv
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?