ESLint - 'process' is not defined

ArunKolhapur picture ArunKolhapur · Jun 17, 2018 · Viewed 29.9k times · Source

I am using ESLinter for a simple node project. Below is the only code I have in 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);

I am using VSCode editor. It automatically runs ESLint for JS code.

In the IDE, I see below error for last but one line -

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

Any Idea what's wrong?

Answer

ArunKolhapur picture ArunKolhapur · Jun 17, 2018

Thanks @FelixKling and @Jaromanda X for quick responses.

I have fixed this with following config for .eslintrc.json file-

{
    "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
    }
}

When I got error I had "browser": true instead of "node": true. Simple mistake.