Visual Studio Code - 类型脚本 - 无法加载 tsconfig.json 和 packages.json 架构

sen*_*der 6 json angularjs visual-studio-code

我正在 Visual Studio Code 中为具有 C# windows 服务后端的应用程序开发 Angular 前端。在没有接触前端的情况下在后端花了几天时间后,我发现 Visual Studio Code 不再会在每次保存时自动重新编译我的打字稿代码。相反,我将不得不 ctrl+c 退出进程并再次运行“npm start”。

我确保 compileOnSave 在我的 tsconfig.json 中设置为 true。这样做时,我注意到一个警告:

Problems loading reference 'http://json.schemastore.org/tsconfig': Unable to load schema from 'http://json.schemastore.org/tsconfig': Unable to to connect to http://json.schemastore.org/tsconfig. Error: getaddrinfo ENOTFOUND json.schemastore.org json.schemastore.org:80
Run Code Online (Sandbox Code Playgroud)

我注意到packages.json 也有类似的警告。我可以在 Google Chrome 上的链接上加载架构。

什么是可能的修复?我可以下载架构并将其手动加载到 Visual Studio Code 中吗?

小智 5

对我来说,这不是代理阻止,而是 VSCode 中的受信任域列表。

转到命令面板上的“管理受信任的域”并添加所需的 url。在这里我们可以添加“ http://json.schemastore.org

这是 VSCode 的白名单,作为一项安全功能,可以阻止它从互联网上的任何地方运行代码。


mal*_*oze 5

更新:

对我来说似乎是网络问题。当我设置Http: proxy正确时,它消失并且json schema运行良好。

http代理设置

jsonschemaworkfine


转到“设置”>“JSON”>“架构下载”并将其禁用。

这对我有用。


sen*_*der 3

正如 @Matt Bierner 在上面的评论中指出的,解决方案是将密钥设置"$schema"为直接到本地模式文件(可以从错误中的地址下载)。

该问题似乎是由网络代理引起的。为什么它现在出现仍然未知。