1. ホーム
  2. javascript

[解決済み] ESLint - 'process'が定義されていません。

2022-08-19 13:44:16

質問

ESLinterをシンプルなnodeプロジェクトに使用しています。以下は、私がindex.jsに持っている唯一のコードです。

const express = require('express');
const app = express();

app.get('/', (req, res) => {
    res.send({
        hi: 'there'
    });
});

const PORT = process.env.PORT || 5000;
app.listen(PORT);

私は VSCode エディタを使用しています。JSコードに対して自動的にESLintが実行されます。

IDEでは、最後の1行を除いて以下のエラーが表示されます。

[eslint] 'process' is not defined. (no-undef)

何が問題なのでしょうか?

どのように解決するのですか?

FelixKlingさん、@Jaromanda Xさん、迅速な対応ありがとうございました。

私は、以下の .eslintrc.json ファイル

{
    "env": {
        "node": true,
        "commonjs": true
    },
    "extends": "eslint:recommended",
    "rules": {
        "indent": [
            "error",
            "tab"
        ],
        "linebreak-style": [
            "error",
            "unix"
        ],
        "quotes": [
            "error",
            "single"
        ],
        "semi": [
            "error",
            "always"
        ]
    },
    "parserOptions": {
        "ecmaVersion": 2015
    }
}

エラーが発生したときは "browser": true の代わりに "node": true . 単純なミスです。