'Project must list all files or use an 'include' pattern
I see this warning thrown in VSCode:
This is the line that throws the ts warning:
import packageJson from "../package.json";
Weirdly, building and linting the project works fine:
$ tsc --project .
✨ Done in 1.16s.
$ tslint --config ../../tslint.json --project .
✨ Done in 1.59s.
Is this a warning caused by the VSCode parser, or is there something wrong in my tsconfig.json file?
// tsconfig.json
{
"exclude": [
"node_modules"
],
"extends": "../../tsconfig.json",
"files": [
"package.json"
],
"include": [
"src/**/*"
],
"compilerOptions": {
/* Basic Options */
"outDir": "dist",
/* Module Resolution Options */
"baseUrl": ".",
}
}
Solution 1:[1]
In my case I was builiding a monorepo and referencing one of the packages in another package.
All I had to do was remove composite: true from tsconfig.json and it worked.
Solution 2:[2]
Try adding:
"resolveJsonModule": true,
"esModuleInterop": true
to your compiler options
Solution 3:[3]
Add package.json to your includes. It out of src dir.
{
"include": [
"src/**/*",
"package.json"
]
}
Solution 4:[4]
Open your tsconfig.node.json, and add your files path in the includes just like "include": ["vite.config.ts", "yourFilePath"],
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Samuel Petroline |
| Solution 2 | Kaca992 |
| Solution 3 | Atombit |
| Solution 4 | RyanZ |

