简体   繁体   English

vscode上的typescript配置

[英]typescript configuration on vscode

I'm getting this message when I go on my vscode : 当我继续我的vscode时,我收到此消息:

The path ...\\node_modules\\typescript\\lib doesn't point to a valid tsserver install. 路径...\\node_modules\\typescript\\lib未指向有效的tsserver安装。

I've no idea what's wrong. 我不知道出了什么问题。 Any ideas? 有任何想法吗?

tsconfig: tsconfig:

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

Perhaps you haven't installed typescript in your project, if so - you can do this by npm install typescript --save-dev . 也许你没有在你的项目中安装typescript ,如果是这样的话 - 你可以通过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: 并且根据Visual Studio Code 文档 - 请检查它对typescript.tsdk使用的路径,也许它应该如下所示:

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

Install the version available in your package.json with the command 使用该命令安装package.json中可用的版本

npm install -g typescript npm install -g typescript

Then hit ctrl+shift+p 然后点击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 bin文件夹的路径,并将其分配给“typescript.lib”

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

Note that the path should be separated by "\\" 请注意,路径应以“\\”分隔

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM