在 VisualStudio2017中更新节点版本

有人知道在 VisualStudio2017中更新 Node 的批准方法吗?我已经在我的开发电脑上设置了 Node 6,但是 VS2017似乎附带了 Node 5的捆绑副本,这意味着在我的命令行上运行 npm install会设置各种类似 node-sass的软件包,并且对 Node 6进行绑定,所以当我从 VS Task Runner 运行吞咽任务时,由于版本不匹配,事情就会失败。

我发现 VS 节点安装在 C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External,但我有点不情愿只是黑客和替换它。有人有升级的经验吗?我知道我可以通过降低我的电脑上的版本同步,但这似乎是向后的。

51491 次浏览

Go to:

Tools > Options > Projects and Solutions > Web Package Management > External Web Tools

Then you need to add your Node install directory to the top of the list, like so:

screenshot

You don't need to add a new Node install directory, Node exists in PATH. Notice how $(PATH) is below the internal 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.

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. enter image description here

It looks as if options in

Tools > Options > Projects and Solutions > Web Package Management > External Web Tools

have no effect. However it is possible to set the Node version through

Project > Properties

Project>properties screenshot

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.

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. 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.

I just wanted to add this here in case someone else runs into this same issue.