1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nuxt.config.jsで.envで定義した値を使う方法

1
Posted at

.envを導入すると

process.env.XXX

.envに定義した値を環境変数としてとってこれます。
便利ですね。

ただnuxt.config.js のファイル内でprocess.env.XXXを使うと.envで定義した値を取得できませんでした。
調べたところ以下の記述

nuxt.config.js
import dotenv from 'dotenv'
dotenv.config()

を書いてやることでprocess.env.XXXが効くようになりました。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?