Visual Studio 2017 - Node.JS 服务器进程 - 关闭?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42769106/
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
Visual Studio 2017 - Node.JS Server Process - Turn off?
提问by Ryan Ternier
I'm working on a ASP.NET App in Visual Studio 2017 and I'm noticing a Node.JS: Server-side Javascript process running at 1.3GB to 1.8GB of memory. My IIS worker process is the normal size it is in VS 2015.
我正在 Visual Studio 2017 中开发一个 ASP.NET 应用程序,我注意到一个 Node.JS:服务器端 Javascript 进程在 1.3GB 到 1.8GB 的内存中运行。我的 IIS 工作进程是 VS 2015 中的正常大小。
My app doesn't include any Node.JS libraries. I'm not able to figure out how to turn this Node.JS: Server-side Javascript process off. It's eating up too much memory for something I have no use for.
我的应用程序不包含任何 Node.JS 库。我不知道如何关闭这个 Node.JS:服务器端 Javascript 进程。它为我没有用的东西消耗了太多内存。
Is there a way to kill this aside from uninstalling VS 2017 and switching back to VS 2015?
除了卸载 VS 2017 并切换回 VS 2015 之外,有没有办法解决这个问题?
Killing the main Process in Task Manager doesn't affect anything in VS, however if I go to the Details tab and kill the the individual running processes it crashes Visual Studio. I took a video of what happened after I killed the process and ran my local web page (Sorry for the quality, SO limited image size to 2MB):
在任务管理器中杀死主进程不会影响 VS 中的任何内容,但是如果我转到“详细信息”选项卡并杀死单个正在运行的进程,它会使 Visual Studio 崩溃。我拍了一段视频,记录了我终止进程并运行我的本地网页后发生的事情(对不起,质量问题,因此图像大小限制为 2MB):
回答by Andy Taw
Tools > Options > Text Editor > JavaScript/TypeScript > Language Service...
工具 > 选项 > 文本编辑器 > JavaScript/TypeScript > 语言服务...
Uncheck 'Enable the new JavaScript language service'.
取消选中“启用新的 JavaScript 语言服务”。
This appears to prevent the NodeJS process from starting.
这似乎会阻止 NodeJS 进程启动。
回答by Ryan Ternier
I raised feedback on this issue:
我就这个问题提出了反馈:
I got response back from a MS Team - he directed me to this post:
我得到了一个 MS 团队的回复——他把我指向了这篇文章:
The node.exe process has the command line:

Effectively I was told:
实际上我被告知:
In VS 2017, several features are implemented in JavaScript. Node.js is used by Visual Studio to run that JavaScript. Among other things, Node is used to run the code that provides formatting and intellisense services when a user is editing TypeScript or JavaScript. This is a change from VS 2015.
在 VS 2017 中,一些特性是用 JavaScript 实现的。Visual Studio 使用 Node.js 来运行该 JavaScript。其中,Node 用于在用户编辑 TypeScript 或 JavaScript 时运行提供格式化和智能感知服务的代码。这是 VS 2015 的变化。
It answers my question, but brings to light another - why do you need 1.4GB of memory to give me intellisense on JavaScript files ... or is this one of the solutions that has been built into VS so it uses Less Memory so it doesn't hit the 2GB(4GB) limit of 32-bit processes? Questions questions questions.
它回答了我的问题,但也揭示了另一个问题——为什么你需要 1.4GB 的内存来为我提供 JavaScript 文件的智能感知……或者这是 VS 内置的解决方案之一,因此它使用更少的内存,所以它不会没有达到 32 位进程的 2GB(4GB) 限制?问题问题问题。
回答by Gabriel
You have to disable TypeScript support on Visual Studio:
您必须在 Visual Studio 上禁用 TypeScript 支持:
Tools > Extensions and Updates > TypeScript for Microsoft Visual Studio > Disable
工具 > 扩展和更新 > TypeScript for Microsoft Visual Studio > 禁用
After that, just restart Visual Studio, and you are good to go.
之后,只需重新启动 Visual Studio,就可以开始了。
回答by Ralph
Ryan Ternier's answer pointed me in what I believe is the right direction. Following his link (https://developercommunity.visualstudio.com/content/problem/27033/nodejs-server-side-javascript-process-consuming-to.html?childToView=27629#comment-27629) led me to Bowden Kelly's answer, right beneath the accepted answer.
Ryan Ternier 的回答为我指明了我认为正确的方向。按照他的链接(https://developercommunity.visualstudio.com/content/problem/27033/nodejs-server-side-javascript-process-sumption-to.html?childToView=27629#comment-27629)让我找到了鲍登凯利的答案,就在接受的答案下方。
Here is Bowden Kelly's answer:
这是鲍登凯利的回答:
The node process you are seeing is powering the JavaScript language service. You will see this process appear anytime you edit a JS file, TS file, or any file with JS/TS inside (html, cshtml, etc). This process is what powers IntelliSense, code navigation, formatting, and other editing features and it does this by analyzing the entire context of your project. If you have a lot of .js files in your project, this can get large, but more than likely the issue is that you have a lot of library files that are being analyzed. By default, we will scan every .js/.ts file in your project. But you can override this behavior and tune the language service to only focus on your code. To do this create a tsconfig.json in your project root with the following settings:
您看到的节点进程正在为 JavaScript 语言服务提供动力。每当您编辑 JS 文件、TS 文件或任何包含 JS/TS 的文件(html、cshtml 等)时,您都会看到此过程出现。这个过程是 IntelliSense、代码导航、格式和其他编辑功能的动力,它通过分析项目的整个上下文来实现。如果您的项目中有很多 .js 文件,这可能会变大,但问题很可能是您有很多正在分析的库文件。默认情况下,我们将扫描您项目中的每个 .js/.ts 文件。但是您可以覆盖此行为并调整语言服务以仅关注您的代码。为此,请使用以下设置在您的项目根目录中创建一个 tsconfig.json:
{
"compilerOptions": {
"allowJs": true,
"noEmit": true
},
"exclude": [
"wwwroot/lib" //ignore everything in the lib folder (bootstrap, jquery, etc)
// add any other folders with library code here
],
"typeAcquisition": {
"enable": true,
"include": [
"bootstrap",
"jquery" //list libraries you are using here
]
}
}
Once I added the folder with all my script libraries into the tsconfig.json file, life was good again.
一旦我将包含所有脚本库的文件夹添加到 tsconfig.json 文件中,生活又恢复了。
回答by user1306322
The dirtiest workaround ever: just rename the ServiceHub.Host.Node.x86.exeto something else. Hasn't bothered me since. When (if) you actually need it, just rename it back.
有史以来最肮脏的解决方法:只需将 重命名ServiceHub.Host.Node.x86.exe为其他名称即可。从那以后就没有打扰我了。当(如果)您确实需要它时,只需将其重命名即可。
Same trick works in Adobe Photoshop which also runs Node for some reason I haven't discovered in my usual workflow yet.
同样的技巧在 Adobe Photoshop 中也有效,由于某些原因,我在通常的工作流程中还没有发现它也运行 Node。
Turns out...
原来...
You can't just rename it and expect things to keep working. Who knew!
你不能只是重命名它并期望它继续工作。谁知道!
Apparently this renaming trick only works if you suspend VS process and kill Node, then resume VS. If you try to launch VS with Node exe file renamed, it will crash when opening a project with an "unknown hard error". Also, while working on an already loaded project, the lazy reference counter above methods and properties won't work because apparently that relies on Node being there somehow.
显然,这种重命名技巧仅在您暂停 VS 进程并杀死 Node,然后恢复 VS 时才有效。如果您尝试使用重命名的 Node exe 文件启动 VS,则在打开具有“未知硬错误”的项目时会崩溃。此外,在处理已经加载的项目时,方法和属性上方的惰性引用计数器将不起作用,因为显然这依赖于 Node 以某种方式存在。
So it might be okay to just suspend the Node process and let Windows paging swap its memory out from ram onto the hard drive, without renaming the exe so you could start the VS again later without going through the renaming hassle. If you're willing to live with the consequences, that is.
因此,暂停 Node 进程并让 Windows 分页将其内存从 ram 交换到硬盘驱动器上可能没问题,而无需重命名 exe,这样您就可以稍后再次启动 VS,而无需经历重命名的麻烦。如果你愿意忍受后果,那就是。
回答by Nathan Teague
Something that can help the projects mitigate the nodejs weight: is to reassign the node version used under Tools > Options > Projects and Solutions > Web Package Managementto an installed 64bit version. Studio will still launch its internal Node for a tsserver.js instance, but any typescript in project will default to the supplied version -- and this helped me firsthand.
可以帮助项目减轻 nodejs 重量的东西:是将工具 > 选项 > 项目和解决方案 > Web 包管理下使用的节点版本重新分配给已安装的 64 位版本。Studio 仍会为 tsserver.js 实例启动其内部节点,但项目中的任何打字稿都将默认为提供的版本——这对我有直接的帮助。
Also, another time I found the language service to be running down, I discovered using a simple tsconfig.jsonabove the directories used as repositories, and specify to skipLibCheck: true, and add node_modules to exclude -- tremendously helped along the service, and one file does all folders beneath it, regardless of direct project references. P.S. -- if you do want JavaScript intellisense support still, make sure to set the allowJs: trueand noEmit: trueoption.
此外,还有一次我发现语言服务正在运行,我发现tsconfig.json在用作存储库的目录上方使用一个简单的,并指定 to skipLibCheck: true,并添加 node_modules 以排除 - 极大地帮助了服务,并且一个文件完成了下面的所有文件夹它,不管直接的项目引用。PS——如果你仍然想要 JavaScript 智能感知支持,请确保设置allowJs: true和noEmit: true选项。
Lastly, verify in the Typescript Options under the Tools > Options > Text Editor > Javascript/Typescript > Projectthat it is not checked to Automatically compile Typescript files which are not part of a projectsince that can also tie up resources for auxillary 3rd party projects using node or typescript.
最后,在“工具”>“选项”>“文本编辑器”>“Javascript/Typescript”>“项目”下的“打字稿选项”中验证是否未选中自动编译不属于项目的打字稿文件,因为这也会占用辅助 3rd 方项目的资源使用节点或打字稿。
These are not fool-proof, each has to find their exact bottleneck, but I have found these have worked for me and my team more often than not
这些都不是万无一失的,每个人都必须找到自己的确切瓶颈,但我发现这些对我和我的团队来说往往有效
回答by zulumojo
Just noting that the high-memory consumption has been fixed in the May 10, 2017 - Visual Studio 2017 version 15.2 (26430.04) Release.
请注意,高内存消耗已在 2017 年 5 月 10 日 - Visual Studio 2017 版本 15.2 (26430.04) 版本中修复。
Release Notes Here: https://www.visualstudio.com/en-us/news/releasenotes/vs2017-relnotes
此处发布说明:https: //www.visualstudio.com/en-us/news/releasenotes/vs2017-relnotes
Specific notes about the fix here: https://developercommunity.visualstudio.com/content/problem/27033/nodejs-server-side-javascript-process-consuming-to.html
关于修复的具体说明:https: //developercommunity.visualstudio.com/content/problem/27033/nodejs-server-side-javascript-process-sumption-to.html
回答by Ben Olayinka
To disable Language Services in VS Code, go to extensions, then filter on builtin extensions and disable the TypeScript/Javascript language service.
要在 VS Code 中禁用语言服务,请转到扩展,然后过滤内置扩展并禁用 TypeScript/Javascript 语言服务。
I finally discovered this after VS code's node service crashed my server about a million times. Annoying that this was so hard to find documentation about.
在 VS Code 的节点服务使我的服务器崩溃大约一百万次之后,我终于发现了这一点。令人烦恼的是,很难找到有关的文档。
回答by Honza P.
In my case I did bot wanted to kill node.js process and I did following things to lower the CPU consumption ov Node.Js processes that run under Visual Studio 2019:
在我的情况下,我确实 bot 想要杀死 node.js 进程,并且我做了以下事情来降低在 Visual Studio 2019 下运行的 Node.Js 进程的 CPU 消耗:
- I removed folder "Program Files (x86)/MicrosoftSDK/TypeScript
- I run
npm rebuild fsevents - I turned off in Chrome browser: Settings-System-Continue running background apps ...
- 我删除了文件夹“Program Files (x86)/MicrosoftSDK/TypeScript
- 我跑
npm rebuild fsevents - 我在 Chrome 浏览器中关闭:设置-系统-继续运行后台应用程序...
It seems to me much better now. But not 100% unfortunatelly.
在我看来现在好多了。但不幸的是,不是 100%。
Hope this helps someone out there too. Good luck guys! :-)
希望这也能帮助那里的人。祝大家好运!:-)

