VSCode is showing errors for jsconfig.json: "File '.../node_modules/dotenv/types' not found."
Appears to be looking for typescript definitions for dotenv, but I'm not using typescript or dotenv (other than in imported packages). And there is a node_modules/dotenv/types
folder.
I had the same issue. Restarting VSCode solved the problem. See: https://github.com/motdotla/dotenv/issues/475
Edit: this seems to be an issue with the contents of dotenv's package.json
. There's an open PR, but the author hasn't replied/merged yet at this time. Link: https://github.com/motdotla/dotenv/pull/476
Edit 2: This should now be fixed! dotenv
v8.4.0 fixes this issue. See https://github.com/motdotla/dotenv/releases/tag/v8.4.0.
You can exclude type checking for dotenv
:
// tsconfig.json or jsconfig.json
"typeAcquisition": {
"exclude": [ "dotenv" ]
}
In this way, typescript will not see this library for auto-type acquisition and then, vscode error will be fixed.
Keep in mind that the changes affect vscode error after a while. Do not assume that see the fix immediately after changing this option.
To see the affection you can restart vscode extension server (Ctrl+Shift+P
And type Restart Extension Host
and press Enter) and wait a few minutes to validate the solution.
The path node_modules/dotenv/types
is referenced as the "types" declaration in dotenv's package.json
.
The problem is that the types declaration should point to a file, not a folder.
So it's a problem with dotenv's package, not with VS Code.
There is an opened PR to fix this problem; until it's merged, you can edit node_modules/dotenv/package.json
and replace "types": "types"
with "types": "types/index.d.ts"
.
Just faced the same issue. Deleting node_modules
and reinstalling all packages fixed this.
I tried all mentioned solutions but none fixed it on my end. So, I tried reopening the code editor and the problem was solved
I was running into the same issue and found that adding this to VSCode settings finally fixed it:
"json.schemas": [
{
"$schema": "https://json.schemastore.org/jsconfig"
}
],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With