javascript - VS 2015 : No highlighting and intellisense in JS files

标签 javascript ide syntax-highlighting intellisense visual-studio-2015

我无法真正重现该问题,但在 .js 文件中没有突出显示或智能感知,但它在 .json 文件中工作得很好。
.js 文件的默认编辑器是 JSON 编辑器。

我尝试了安全模式、禁用所有扩展、重置所有设置,甚至重新安装了 IDE(修复),但问题仍然存在。

我要补充一点,当我启动 IDE 并且在范围内打开 JS 文件时,我收到以下错误消息(突出显示和智能感知无论如何都不起作用):

The 'JavaScriptWebExtensionPackage' package did not load correctly.

The problem may have been caused by a configuration change or by the installation of another extension. You can get more information examining the file 'C:\Users\Shimmy\AppData\Roaming\Microsoft\VisualStudio\14.0\ActivityLog.xml'.

Restarting Visual Studio could help resolve the issue.

Continue to show this error message?

Here您可以查看 ActivityLog.xml 文件,我粘贴了一些我认为可能相关的最近行:

<entry>
  <record>188</record>
  <time>2015/08/14 13:00:57.332</time>
  <type>Information</type>
  <source>VisualStudio</source>
  <description>Begin package load [JavaScriptWebExtensionsPackage]</description>
  <guid>{30DB8F9B-EC9F-44D6-B377-83C7C27A1A8B}</guid>
</entry>
<entry>
  <record>189</record>
  <time>2015/08/14 13:00:57.394</time>
  <type>Error</type>
  <source>VisualStudio</source>
  <description>SetSite failed for package [JavaScriptWebExtensionsPackage]</description>
  <guid>{30DB8F9B-EC9F-44D6-B377-83C7C27A1A8B}</guid>
  <hr>80131500</hr>
  <errorinfo>Expected 1 export(s) with contract name "Microsoft.VisualStudio.JavaScript.Web.Extensions.ReferenceAutoSync.IReferencesFilePathProvider" but found 0 after applying applicable constraints.</errorinfo>
</entry>
<entry>
  <record>190</record>
  <time>2015/08/14 13:00:57.394</time>
  <type>Error</type>
  <source>VisualStudio</source>
  <description>End package load [JavaScriptWebExtensionsPackage]</description>
  <guid>{30DB8F9B-EC9F-44D6-B377-83C7C27A1A8B}</guid>
  <hr>80131500</hr>
  <errorinfo>Expected 1 export(s) with contract name "Microsoft.VisualStudio.JavaScript.Web.Extensions.ReferenceAutoSync.IReferencesFilePathProvider" but found 0 after applying applicable constraints.</errorinfo>
</entry>

最佳答案

我在这里找到答案:Visual Studio 2015 RTM - Lost JavaScript support after update TypeSript Tools

修复此问题的步骤如下:

If the “Universal Windows App Development Tools” are still installed:

  1. Go to Programs and Features, select Visual Studio 2015, click Change.
  2. In Visual Studio setup, click Modify.
  3. Deselect the feature “Universal Windows App Development Tools”
  4. Select “Universal Windows App Development Tools” again, and click Update.

If you have already uninstalled the “Universal Windows App Development Tools”:

  • Reinstall “Universal Windows App Development Tools”
  • Or, take the following steps to reinstall the JavaScript project system and language service:
    1. Download the installer for your edition of Visual Studio, e.g., vs_community.exe.
    2. Open a CMD window, and run the following command: vs_community.exe /modify /installselectableitems JavaScript_Hidden /passive

我已经完成了第一步并重新获得了 Javascript 支持。

希望这有帮助

-更新-

完成上述步骤后,几乎一切正常,除了每次打开 .js 文件时都会收到一条错误消息,以下方法解决了问题:

我的猜测是,仅重新安装 SDK 并没有更新 MEF 缓存。您可以按照以下步骤手动执行此操作:

Open a command prompt as administrator

  1. CD into C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
  2. Run devenv /updateconfiguration
  3. Run devenv /clearcache

这消除了最后一个错误,一切正常。

来源:https://github.com/Microsoft/TypeScript/issues/4238

关于javascript - VS 2015 : No highlighting and intellisense in JS files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32000562/

相关文章:

javascript - Sublime Javascript 关键字突出显示

version-control - Netbeans 版本控制文件颜色代码?

delphi - 框架继承和包中的重复文件

javascript - 在 AJAX 加载的内容上使用语法荧光笔

javascript - 需要将两个对象合并在一起,每个对象都有一个匹配 ID 的数组

.net - 如何在 VS2008 中禁用 Cider(WPF Gui 编辑器)?

vim - 如何在 Vim 中的注释中禁用拼写高亮显示

javascript - d3js : how to put circles at the end of an arc

javascript - (Javascript) 正则表达式特定字符但不包括

javascript - Firefox 在第一次访问时不会绘制到 Canvas 上