Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
    ]
}
like image 895
Jordi Avatar asked Dec 09 '16 07:12

Jordi


People also ask

Is Vscode good for TypeScript?

Visual Studio Code includes TypeScript language support but does not include the TypeScript compiler, tsc . You will need to install the TypeScript compiler either globally or in your workspace to transpile TypeScript source code to JavaScript ( tsc HelloWorld. ts ). You can test your install by checking the version.


2 Answers

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"
}
like image 103
eko24ive Avatar answered Oct 05 '22 02:10

eko24ive


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 "\"

like image 22
Narayanan K Avatar answered Oct 05 '22 02:10

Narayanan K