node.js 在 Visual Studio 2017 中更新节点版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43849585/
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-09-02 18:13:00  来源:igfitidea点击:

Update Node Version in Visual Studio 2017

node.jsvisual-studiovisual-studio-2017

提问by Henry Wilson

Does anyone know of a sanctioned way to update Node within Visual Studio 2017? 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 installon my command line sets up various packages like node-sasswith bindings for Node 6, so when I then run gulp tasks from the VS Task Runner things fall over due to the mismatched versions.

有谁知道在 Visual Studio 2017 中更新 Node 的认可方法?我已经在我的开发 PC 上设置了 Node 6,但 VS2017 似乎附带了 Node 5 的捆绑副本,这意味着npm install在我的命令行上运行会设置各种包,例如node-sassNode 6 的绑定,所以当我运行 gulp 时来自 VS Task Runner 的任务由于版本不匹配而失败。

I found the VS Node install at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\Externalbut I'm a little reluctant to just hack about and replace it. Anyone got any experience of upgrading this? I know I can sync by downgrading the version on my PC but that seems backwards.

我找到了 VS Node 安装,C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External但我有点不愿意直接破解并替换它。有人有升级这个的经验吗?我知道我可以通过降级 PC 上的版本来同步,但这似乎倒退了。

回答by Joe Clay

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 安装目录添加到列表顶部,如下所示:

screenshot

截屏

回答by Eduardo Yupanqui Quispe

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.

您不需要添加新的 Node 安装目录,Node 存在于 PATH 中。请注意$(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. enter image description here

这是在搜索内部路径之前搜索全局路径时的样子,因此将使 Visual Studio 使用您自己的工具版本。 在此处输入图片说明

回答by JMaFv

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

项目 > 属性

Project>properties screenshot

项目>属性截图

回答by Joseph

For me, the issue turned out to be that there was a local node.exefile in the same directory that the csprojfile was in, along with a node.exe.configfile.

对我来说,问题原来是在node.exe文件所在的同一目录中有一个本地文件csproj,还有一个node.exe.config文件。

I had a post-build event that would call gulpto do some other work and VS2017 would use the local node.exefile 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.exeso the one listed in $(PATH)would be used or upgrade the local node.exefile if the node.exe.configis really needed.

我有一个构建后事件,它会调用gulp做一些其他工作,而 VS2017 将使用本地node.exe文件而不是我的$(PATH)变量中列出的文件。这是我不想使用的较早版本的节点,因此我的解决方案是删除本地文件node.exe以便使用中列出$(PATH)node.exe文件或升级本地文件(如果node.exe.config确实需要)。

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

我只是想在这里添加这个以防其他人遇到同样的问题。