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

はじめに

こんにちは、エンジニアのkeitaMaxです。

Next.jsでESLintを入れた時に'process' is not defined.というエラーが出て困ったことがあったので備忘録として残そうと思います。

困ったこと

const apiURL: string | undefined = process.env.NEXT_PUBLIC_BACKEND_URL ?? ''

こんな感じでenvファイルを読み込もうとした時にESLintで'process' is not defined.というエラーが表示されてしまいました。

解決策

ESLintの設定ファイルのenvに"node": trueを追加したら直りました。

.eslintrc.json
{
  "env": {
    "browser": true,
    "es2021": true,
    "jest": true,
    "node": true
  },

Node.js環境をESLintに追加し、processが定義されるようになりました。

おわりに

この記事での質問や、間違っている、もっといい方法があるといったご意見などありましたらご指摘していただけると幸いです。

最後まで読んでいただきありがとうございました!

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