简体   繁体   English

在Visual Studio 2017中更新节点版本

[英]Update Node Version in Visual Studio 2017

Does anyone know of a sanctioned way to update Node within Visual Studio 2017? 有没有人知道在Visual Studio 2017中更新Node的制裁方法? I've got Node 6 set up on my development PC but VS2017 appears to come with a bundled copy of Node 5, which means that running npm install on my command line sets up various packages like node-sass with bindings for Node 6, so when I then run gulp tasks from the VS Task Runner things fall over due to the mismatched versions. 我已经在我的开发PC上设置了Node 6,但是VS2017似乎附带了Node 5的捆绑副本,这意味着在我的命令行上运行npm install设置各种包,例如node-sass和Node 6的绑定,所以当我从VS任务运行器运行gulp任务时,由于版本不匹配,事情会崩溃。

I found the VS Node install at C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Web\\External but I'm a little reluctant to just hack about and replace it. 我发现VS节点安装在C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Web\\External但是我有点不愿意破解并替换它。 Anyone got any experience of upgrading this? 有人有升级经验吗? I know I can sync by downgrading the version on my PC but that seems backwards. 我知道我可以通过降级我的电脑上的版本进行同步,但这似乎是倒退。

Go to: 去:

Tools > Options > Projects and Solutions > Web Package Management > External Web Tools 工具>选项>项目和解决方案> Web包管理>外部Web工具

Then you need to add your Node install directory to the top of the list, like so: 然后,您需要将Node安装目录添加到列表顶部,如下所示:

截图

You don't need to add a new Node install directory, Node exists in PATH. 您不需要添加新的节点安装目录,节点存在于PATH中。 Notice how $(PATH) is below the internal path $(DevEnvDir)\\Extensions\\Microsoft\\Web Tools\\External . 注意$(PATH)如何低于内部路径$(DevEnvDir)\\ Extensions \\ Microsoft \\ Web Tools \\ External

To use the global PATH environment variable before the internal path, you can just use the arrows at the top-right to change the order. 要在内部路径之前使用全局PATH环境变量,只需使用右上角的箭头即可更改顺序。

This is what it looks like when the global PATH is searched before the internal one and therefore will make Visual Studio use your own versions of the tools. 这是在内部PATH之前搜索全局PATH时的样子,因此将使Visual Studio使用您自己的工具版本。 在此输入图像描述

It looks as if options in 看起来好像是选项

Tools > Options > Projects and Solutions > Web Package Management > External Web Tools 工具>选项>项目和解决方案> Web包管理>外部Web工具

have no effect. 没有效果。 However it is possible to set the Node version through 但是可以通过设置节点版本

Project > Properties 项目>属性

项目>属性截图

For me, the issue turned out to be that there was a local node.exe file in the same directory that the csproj file was in, along with a node.exe.config file. 对我来说,这个问题竟然是,有一个地方node.exe在同一目录下,文件csproj文件是与沿着node.exe.config文件。

I had a post-build event that would call gulp to do some other work and VS2017 would use the local node.exe file rather than what was listed in my $(PATH) variable. 我会叫一个生成后事件gulp做一些其他的工作,VS2017将使用本地node.exe文件,而不是什么在我列出的$(PATH)变量。 This was an earlier version of node that I didn't want to use, so the solution for me was to either remove the local node.exe so the one listed in $(PATH) would be used or upgrade the local node.exe file if the node.exe.config is really needed. 这是我不想使用的早期版本的节点,所以我的解决方案是删除本地node.exe以便使用$(PATH)列出的node.exe或升级本地node.exe文件如果确实需要node.exe.config

I just wanted to add this here in case someone else runs into this same issue. 我只是想在这里添加它,以防其他人遇到同样的问题。

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

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