vscode: typescript/lib/lib.d.ts not found in all jsconfig.json files without target

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.74.0 and 1.75.0-insider
  • OS Version: Windows 11 x64 10.0.22621

Every project on my local system containing a jsconfig.json file without a target property has started reporting this error:

File 'd:/Program Files/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.d.ts' not found.
  The file is in the program because:
    Default library for target 'es3'

Some projects have it multiple times, others only once. I freshly installed insiders to test, with no settings or extensions, and it occurs there too.

It doesn’t occur if you have target as one of your compiler options, but this wasn’t necessary before. My code isn’t compiled with typescript; I use jsconfig so vscode recognizes my files as being part of the same project, and other similar reasons.

Working as normal when target is specified: 2022-12-08-Code_-_Insiders-1670492789

Examples of the issue: 2022-12-08-Code_-_Insiders-1670491612 2022-12-08-Code-1670491586

Steps to Reproduce:

  1. Open an empty folder in vscode
  2. Create an empty index.js file
  3. Create a jsconfig.json with valid properties without specifying a compiler options target.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 19
  • Comments: 27 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I also had this error in tsconfig.node.json. I restarted TS Server in VSCode and then it fixed.

cmd + shift + p

image

Added "target": "esnext" and now it just works.

# tsconfig.node.js
{
  "compilerOptions": {
    "target": "esnext",
    "composite": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "allowSyntheticDefaultImports": true
  },
  "include": [
    "vite.config.ts"
  ]
}

Here is what worked for me!

Close the VS Code.

yarn global add next@latest yarn global add typescript@latest

Open your project rm -rf node_modules package-lock.json

Re-open your project!

Also, check your VS Code extension, Install the official Javascript & Typescript extension by Microsoft.

I hope this helps!

I also had this error in tsconfig.node.json. I restarted TS Server in VSCode and then it fixed.

cmd + shift + p

image

I tried this, but it didn’t work for me. I thought I was the only one with this issue after updating VS Code.

EDIT: So, what I did to fix this issue was copy a lib.d.ts file from a recent project I worked on to the lib directory. The error was no longer present after saving via the jsconfig.json file.

Before: image

After: image

EDIT #2: I downloaded an older version of VS Code for macOS (1.73.1) and copied the file from Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/lib.d.ts. The reason was because the current version (1.74.0) did not have the file in the lib directory. I observed some of the lib.d.ts files on my Mac were different. The file in the lib directory looks like this:

image

Here is the code:

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */



/// <reference no-default-lib="true"/>


/// <reference lib="es5" />
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />

Added "target": "esnext" and now it just works.

# tsconfig.node.js
{
  "compilerOptions": {
    "target": "esnext",
    "composite": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "allowSyntheticDefaultImports": true
  },
  "include": [
    "vite.config.ts"
  ]
}

Thanks man. It’s worked for me.

Thanks @sagargulati I just install the extension and with that works

Seems fixed on Update 1.74.1. Thanks!

Added “target”: “ESNext” and now it just works. { “compilerOptions”: { “target”: “ESNext”, “composite”: true, “module”: “ESNext”, “moduleResolution”: “Node”, “allowSyntheticDefaultImports”: true }, “include”: [“vite.config.ts”] }

I just did

cmd + shift + p

and used the Workspace version instead of VS Code. It worked.

image

Same question, when creating vite project:

pnpm create vite
# config...

cd my-proj
pnpm i
pnpm dev

9 Errors in tsconfig.node.json:

[{
	"resource": "/d:/WorkSpace/sanic-vue-exam/vue-simple-exam/tsconfig.node.json",
	"owner": "typescript",
	"severity": 8,
	"message": "File 'd:/Pro/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.d.ts' not found.\n  The file is in the program because:\n    Default library for target 'es3'",
	"source": "ts",
	"startLineNumber": 1,
	"startColumn": 1,
	"endLineNumber": 1,
	"endColumn": 2
}]

Thank you @sagargulati. Installing the extension and restarting VSCode worked for me.

It worked for me too 😃

I am also having this issue on Mac Ventura. Restarting the Typescript server or even restarting VS Code only solves the problem for a few minutes, then it resurfaces.

Igual me esta pasando, de la nada salio el problema.

Problem fixed on Update@1.74.1

add “target”: “esVersion” with esVersion like es6, es2017, es2020, … in compilerOptions this worked for me 😃

I also had this error in tsconfig.node.json. I restarted TS Server in VSCode and then it fixed.

cmd + shift + p

image

This worked for me. Thanks