VS 2015:JS文件中没有突出显示和智能感知

时间:2015-08-14 00:29:02

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

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

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

我将补充说,当我启动IDE并且JS文件在作用域上打开时,我收到以下错误消息(突出显示并且intellisense无论如何都不起作用):

  

JavaScriptWebExtensionPackage'包没有正确加载。

     

问题可能是由配置更改或安装其他扩展程序引起的。您可以获取更多信息来检查文件' C:\ Users \ Shimmy \ AppData \ Roaming \ Microsoft \ VisualStudio \ 14.0 \ ActivityLog.xml'。

     

重新启动Visual Studio可以帮助解决问题。

     

继续显示此错误消息?

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>

3 个答案:

答案 0 :(得分:34)

I found answer here: Visual Studio 2015 RTM - Lost JavaScript support after update TypeSript Tools

These are the steps to fix it:

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

I've followed the first steps and got back Javascript support.

Hope this helps

-UPDATED-

After I did the above steps, almost everything was working, except that I got an error message every time I opened a .js file, the following did the trick:

My guess is that only reinstalling the SDK didn't update the MEF cache. You can do this manually by following these steps:

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

That got rid of the last error, and everything is working fine.

Source: https://github.com/Microsoft/TypeScript/issues/4238

答案 1 :(得分:1)

这个问题似乎在Update 1上修复了。我在专业版上,但我想它适用于所有版本。

要明确的是,Intellisense对我来说并不适用于razor文件上的css相关内容,并且在更新1后它似乎正在工作。

答案 2 :(得分:1)

我知道这个问题显然是针对Visual Studio 2015。

但是,如果接受的答案也适用于 Visual Studio 2017 ,我想把我的两分钱用于那些拼命试用的人。

在我的情况下,语法突出显示的丢失是由新的JavaScript语言服务引起的。我在取消选中以下复选框并重新启动Visual Studio后立即找回它:

  

工具&gt;选项&gt;文本编辑器&gt; JavaScript / TypeScript&gt;语言   服务&gt;启用新的JavaScript语言服务。*

参考:https://developercommunity.visualstudio.com/comments/34109/view.html

相关问题