Jordi
Jordi

Reputation: 23277

typescript configuration on vscode

I'm getting this message when I go on my vscode:

The path ...\node_modules\typescript\lib doesn't point to a valid tsserver install.

I've no idea what's wrong. Any ideas?

tsconfig:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "declaration": true,
        "baseUrl": "./ts",
        "outDir": "js"
    },
    "exclude": [
        "node_modules",
        "js"
    ]
}

Upvotes: 17

Views: 13594

Answers (3)

Tuxman
Tuxman

Reputation: 398

If you use Linux (Ubuntu, etc...), open .vscode/settings.json and change the \ char for /. Example:

Before:

"typescript.tsdk": "node_modules\\typescript\\lib",

After

"typescript.tsdk": "node_modules/typescript/lib",

This change fix the message at startup.

Upvotes: 1

Narayanan K
Narayanan K

Reputation: 59

Install the version available in your package.json with the command

npm install -g typescript

Then hit ctrl+shift+p

Enter "Open user settings"

In the user settings copy the path of Typescript bin folder from node modules and assign it to "typescript.lib"

"typescript.tsdk": "D:\SampleFolder\Samplesubfolder\Sampleproject\node_modules\typescript\lib",

Note that the path should be separated by "\"

Upvotes: 5

eko24ive
eko24ive

Reputation: 450

Perhaps you haven't installed typescript in your project, if so - you can do this by npm install typescript --save-dev.
And accoring to Visual Studio Code documentation - please check path it's use for typescript.tsdk, maybe it should look like this:

{
   "typescript.tsdk": "./node_modules/typescript/lib"
}

Upvotes: 14

Related Questions