I've been working on setting up TypeScript and ESLint for my new Node.js Express app, but I keep encountering the
Error: Could not find config file.
Here's a glimpse of my package.json:
{
//#######
//#######
"scripts": {},
"dependencies": {
"express": "^4.19.2"
},
"devDependencies": {
"@types/express": "^4.17.21",
"@types/node": "^20.12.13",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"eslint": "^9.3.0",
"eslint-plugin-node": "^11.1.0",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
}
}
Furthermore, here is the content of my tsconfig.json
file:
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"rootDir": "./src",
"moduleResolution": "Node",
"resolveJsonModule": true,
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitAny": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"skipLibCheck": true
},
"include": ["src/**/*", ".eslintrc.js"],
"exclude": ["node_modules"]
}
As for my eslintrc.js
file, it looks like this:
module.exports = {
env: {
node: true,
commonjs: true,
es6: true,
},
root: true,
extends: [
'eslint:recommended',
'plugin:node/recommended',
'plugin:@typescript-eslint/recommended',
],
parser: '@typescript-eslint/parser',
ignorePatterns: ['.eslintrc.js', 'node_modules'],
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint', '@typescript-eslint/eslint-plugin'],
rules: {
'@typescript-eslint/interface-name-prefix': 'warn',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-explicit-any': 'error',
},
};
I have attempted to make modifications in the eslintrc file by adding and removing lines, but the issue persists. The TypeScript server is running smoothly, however, I can't seem to pinpoint what exactly is causing the problem.
If anyone could offer some assistance, I would greatly appreciate it!