Visual Studio 2017中的gulp集成无法正常工作 [英] gulp integration in Visual Studio 2017 not working

查看:213
本文介绍了Visual Studio 2017中的gulp集成无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将gulp集成到Visual Studio 2017中.它正在命令行上工作. VS2017中的Task Runner Explorer告诉我Failed to load. See output window.

I'm attempting to get gulp integration into Visual Studio 2017. It's working on the command line. The Task Runner Explorer in VS2017 is telling me Failed to load. See output window.

输出"窗口告诉我以下内容:

The Output Window is telling me the following:

Failed to run "<ProjectPath>\Gulpfile.js"...
cmd.exe /c gulp --tasks-simple
<ProjectPath>\node_modules\node-sass\lib\binding.js:15
      throw new Error(errors.missingBinary());
      ^
Error: Missing binding <ProjectPath>\node_modules\node-sass\vendor\win32-x64-47\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 5.x
Found bindings for the following environments:
  - Windows 64-bit with Node.js 8.x
This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass --force` to build the binding for your current environment.

我试图运行npm rebuild node-sass --force,只是被告知Error: Can't find Python executable "C:\Python36\python.EXE", you can set the PYTHON env variable.,我确认存在.

I attempt to run npm rebuild node-sass --force, only to be told Error: Can't find Python executable "C:\Python36\python.EXE", you can set the PYTHON env variable., which I confirmed existed.

我不确定我想在这个兔子洞里走多远.这似乎是一个VS问题,因为一切都可以在命令行上按预期工作.我想使与VS的gulp集成正常工作.

I'm not sure how much farther I want to go down this rabbit hole. It appears to be a VS issue since everything works as expected on the command line. I'd like to get the gulp integration with VS working correctly.

推荐答案

将VS工具指向路径上的节点安装.

Point your VS tools to the node installation on your path.

我可以看到在错误中5.x8.x之间存在版本差异-VS可能是较旧的版本(因为它附带了预打包和过时的节点),并且以默认优先执行设置.

I can see in the error that there a version discrepancy between 5.x and 8.x - with VS likely being the older one (since it ships with pre-packaged and outdated node) and is taking execution precedence with the default setup.

我猜您是通过8.x(外部命令行)实例安装了node-sass,但是VS试图通过VS的内部5.x执行您的任务. node-sass利用 node-gyp 通过

I'm guessing you installed node-sass via your 8.x (external command line) instance but VS is trying to execute your gulp tasks via your VS's internal 5.x. node-sass leverages node-gyp to build a binary via installation scripts, and there will be incompatibilities across versions. In other words, this package, and many others that build binaries, are specifically tailored to the version of node it was installed against. To summarize, everything in node_modules/.bin is built against 8.x but is actually running on 5.x when you do so through Visual Studio.

不要害怕,这很容易解决.查看

Fear not, this is easily solved. Check out this answer for some historical context on this long running issue that many face. Basically, you want $(PATH) to be at the top of this list so your OS installation is always used...

一旦执行此操作(为了安全起见)-吹走node_modules,重新安装,并进行满意的编码. VS确实需要停止使用固定版本的节点来发货...

Once you do this (just to be safe) - blow away node_modules, reinstall, and happy coding. VS really needs to stop shipping with pinned versions of node...

这篇关于Visual Studio 2017中的gulp集成无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆