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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32000562/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 14:43:25  来源:igfitidea点击:

VS 2015: No highlighting and intellisense in JS files

javascriptidesyntax-highlightingintellisensevisual-studio-2015

提问by Shimmy Weitzhandler

I can't really reproduce the issue, but no highlighting or intellisense is working in .jsfiles, it works just fine in .jsonfiles however.
The default editor for .jsfiles is JSON Editor.

我无法真正重现这个问题,但是文件中没有突出显示或智能感知,但是.js它在文件中工作得很好.json。文件
的默认编辑器.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 文件时,我收到以下错误消息(无论如何,突出显示和智能感知都不起作用):

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?

'JavaScriptWebExtensionPackage' 包未正确加载。

该问题可能是由配置更改或安装另一个扩展引起的。您可以通过检查文件“C:\Users\Shimmy\AppData\Roaming\Microsoft\VisualStudio\14.0\ActivityLog.xml”获得更多信息。

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

继续显示此错误消息?

Hereyou can view the ActivityLog.xmlfile, 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>

回答by Eduardo Roth

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

我在这里找到了答案:Visual Studio 2015 RTM - 更新 TypeSript 工具后丢失 JavaScript 支持

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

如果仍然安装了“通用 Windows 应用程序开发工具”:

  1. 转到程序和功能,选择 Visual Studio 2015,单击更改。
  2. 在 Visual Studio 安装程序中,单击修改。
  3. 取消选择“通用 Windows 应用程序开发工具”功能
  4. 再次选择“Universal Windows App Development Tools”,然后单击“更新”。

如果您已经卸载了“Universal Windows App Development Tools”:

  • 重新安装“通用 Windows 应用程序开发工具”
  • 或者,按照以下步骤重新安装 JavaScript 项目系统和语言服务:
    1. 下载适用于您的 Visual Studio 版本的安装程序,例如 vs_community.exe。
    2. 打开 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. You can do this manually by following these steps:

我的猜测是仅重新安装 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

以管理员身份打开命令提示符

  1. CD 到 C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
  2. 运行 devenv /updateconfiguration
  3. 运行 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

回答by ManyRootsofAllEvil

The issue seems to be fixed on Update 1. I'm on the professional version but I imagine that it applies to all versions.

该问题似乎已在更新 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 不适用于我在 razor 文件和 post update 1 上的 css 相关内容,它似乎正在工作。

回答by Alan

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. I got it back right after deselecting the following checkbox and restarting Visual Studio:

就我而言,语法高亮丢失是由新的 javascript 语言服务引起的。在取消选中以下复选框并重新启动 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