Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
34
rated 0 times [  36] [ 2]  / answers: 1 / hits: 85320  / 6 Years ago, sun, june 17, 2018, 12:00:00

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?


More From » node.js

 Answers
13

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


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

Thanks @FelixKling and @Jaromanda X for quick responses.


[#54187] Wednesday, June 13, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
clifford

Total Points: 86
Total Questions: 114
Total Answers: 111

Location: Wales
Member since Mon, May 17, 2021
3 Years ago
;