简体   繁体   English

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

[英]VS 2015: No highlighting and intellisense in JS files

I can't really reproduce the issue, but no highlighting or intellisense is working in .js files, it works just fine in .json files however. 我无法真正重现这个问题,但是没有突出显示或intellisense在.js文件中工作,但它在.json文件中工作正常。
The default editor for .js files is JSON Editor. .js文件的默认编辑器是JSON编辑器。

I tried safe-mode, disabling all extensions, resetting all settings, and I even reinstalled the IDE (repair), but the issue still persists. 我尝试了安全模式,禁用所有扩展,重置所有设置,我甚至重新安装了IDE(修复),但问题仍然存在。

I will add, that when I launch the IDE and a JS file is open on scope, I get the following error message (highlighting and intellisense don't work anyway): 我将补充一点,当我启动IDE并且JS文件在作用域上打开时,我收到以下错误消息(突出显示和intellisense无论如何都不起作用):

The 'JavaScriptWebExtensionPackage' package did not load correctly. “JavaScriptWebExtensionPackage”包未正确加载。

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'. 您可以获取更多信息检查文件'C:\\ Users \\ Shimmy \\ AppData \\ Roaming \\ Microsoft \\ VisualStudio \\ 14.0 \\ ActivityLog.xml'。

Restarting Visual Studio could help resolve the issue. 重新启动Visual Studio可以帮助解决此问题。

Continue to show this error message? 继续显示此错误消息?

Here you can view the ActivityLog.xml file, I pasted in some of the recent lines I think might be relevant: 在这里,您可以查看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>

I found answer here: Visual Studio 2015 RTM - Lost JavaScript support after update TypeSript Tools 我在这里找到了答案: Visual Studio 2015 RTM - 更新TypeSript Tools后失去了JavaScript支持

These are the steps to fix it: 以下是修复它的步骤:

If the “Universal Windows App Development Tools” are still installed: 如果仍安装“通用Windows应用程序开发工具”:

  1. Go to Programs and Features, select Visual Studio 2015, click Change. 转到“程序和功能”,选择“Visual Studio 2015”,单击“更改”。
  2. In Visual Studio setup, click Modify. 在Visual Studio安装程序中,单击“修改”。
  3. Deselect the feature “Universal Windows App Development Tools” 取消选择“通用Windows应用程序开发工具”功能
  4. Select “Universal Windows App Development Tools” again, and click Update. 再次选择“通用Windows应用程序开发工具”,然后单击“更新”。

If you have already uninstalled the “Universal Windows App Development Tools”: 如果您已经卸载了“通用Windows应用程序开发工具”:

  • Reinstall “Universal Windows App Development Tools” 重新安装“通用Windows应用程序开发工具”
  • Or, take the following steps to reinstall the JavaScript project system and language service: 或者,执行以下步骤以重新安装JavaScript项目系统和语言服务:
    1. Download the installer for your edition of Visual Studio, eg, vs_community.exe. 下载适用于您的Visual Studio版本的安装程序,例如vs_community.exe。
    2. Open a CMD window, and run the following command: vs_community.exe /modify /installselectableitems JavaScript_Hidden /passive 打开CMD窗口,然后运行以下命令:vs_community.exe / modify / installselectableitems JavaScript_Hidden / passive

I've followed the first steps and got back Javascript support. 我已经按照第一步的步骤获得了Javascript支持。

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: 在我完成上述步骤后,几乎所有内容都正常工作,除了每次打开.js文件时都收到错误消息,以下是诀窍:

My guess is that only reinstalling the SDK didn't update the MEF cache. 我的猜测是只重新安装SDK没有更新MEF缓存。 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 CD到C:\\ Program Files(x86)\\ Microsoft Visual Studio 14.0 \\ Common7 \\ IDE
  2. Run devenv /updateconfiguration 运行devenv / updateconfiguration
  3. Run devenv /clearcache 运行devenv / clearcache

That got rid of the last error, and everything is working fine. 摆脱了最后一个错误,一切正常。

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

The issue seems to be fixed on Update 1. I'm on the professional version but I imagine that it applies to all versions. 这个问题似乎在Update 1上修复了。我在专业版上,但我想它适用于所有版本。

To be clear, Intellisense was not working for me for css related stuff on razor files and post update 1 it seems to be working. 要明确的是,Intellisense对我来说并不适用于剃刀文件上的css相关内容,并且在更新1之后它似乎正在工作。

I know this question is clearly targeting Visual Studio 2015. 我知道这个问题显然是针对Visual Studio 2015。

However, I wanted to put my two cents in for those who desperately tried out if the accepted answer also works for Visual Studio 2017 . 但是,如果接受的答案也适用于Visual Studio 2017 ,我想把我的两分钱用于那些拼命试用的人。

In my case, the loss of syntax highlighting was caused by the new javascript language service. 就我而言,语法突出显示的丢失是由新的JavaScript语言服务引起的。 I got it back right after deselecting the following checkbox and restarting Visual Studio: 我在取消选择以下复选框并重新启动Visual Studio后立即将其取回:

Tools > Options > Text Editor > JavaScript/TypeScript > Language Service > Enable the new JavaScript language service.* 工具>选项>文本编辑器> JavaScript / TypeScript>语言服务>启用新的JavaScript语言服务。*

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

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

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