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?

.envの使い方(備忘録)

0
Posted at

はじめに

.envで環境変数を管理する。
そんな話は聞いたことがありましたが、実感として、どのような使い方をするのか、わかっていませんでした。

今回は備忘録も兼ねて、残していきたいと思います。

.gitignoreに記載

まずは、環境変数を外部に漏らさないように、.gitignoreしておきます。

.env

怖いですからね。

.envに記載

次に、環境変数の値を設定します。

XXX_TOKEN=値

呼び出し

最後に呼び出します。

const TOKEN = process.env.XXX_TOKEN;

まとめ

以下の記事を参考にdiscordでbotを作る際に、そういえば、.envって話があったよなぁ、と思い、活用してみました。

参考

以下の記事を参考にさせていただきました

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?