【问题标题】:VS Task Runner Explorer - Node Sass could not find a bindingVS Task Runner Explorer - Node Sass 找不到绑定
【发布时间】:2017-04-12 06:37:18
【问题描述】:

打开 Visual Studio Task Runner Explorer 时,gulpfile.js 无法加载,并且在“输出”窗口中发出此错误。

Failed to run "C:\DATA\Git\MyApp\MyBiz.MyApp\MyBiz.MyApp.WebsiteCore\Gulpfile.js"...
cmd.exe /c gulp --tasks-simple
C:\DATA\Git\MyApp\MyBiz.MyApp\MyBiz.MyApp.WebsiteCore\node_modules\node-sass\lib\binding.js:15
      throw new Error(errors.missingBinary());
      ^
Error: Missing binding C:\DATA\Git\MyApp\MyBiz.MyApp\MyBiz.MyApp.WebsiteCore\node_modules\node-sass\vendor\win32-ia32-47\binding.node
Node Sass could not find a binding for your current environment: Windows 32-bit with Node.js 5.x
Found bindings for the following environments:
  - Windows 64-bit with Node.js 6.x
This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to build the binding for your current environment.
    at module.exports (C:\DATA\Git\MyApp\MyBiz.MyApp\MyBiz.MyApp.WebsiteCore\node_modules\node-sass\lib\binding.js:15:13)
    at Object.<anonymous> (C:\DATA\Git\MyApp\MyBiz.MyApp\MyBiz.MyApp.WebsiteCore\node_modules\node-sass\lib\index.js:14:35)
    at Module._compile (module.js:397:26)
    at Object.Module._extensions..js (module.js:404:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\DATA\Git\MyApp\MyBiz.MyApp\MyBiz.MyApp.WebsiteCore\node_modules\gulp-sass\index.js:187:21)
    at Module._compile (module.js:397:26)

运行 gulp 运行任务,我的 SASS 编译正常。

我尝试重新安装节点,我还确保只有一个npm runnable 在 Windows 路径中,我删除了node_modules 文件夹并运行了几次npm install,还尝试了npm rebuild node-sass

所有这些数以百万计的很酷的新前端工具和库似乎极大地拓宽了“出错的地方”的范围,与以前的项目相比,效率并不高。

卢克

【问题讨论】:

  • 惭愧地说我放弃并回到 ASP.NET MVC 5 :-/

标签: node.js visual-studio-2015 npm sass gulp


【解决方案1】:

我在 VS 2019 中遇到了同样的问题。以下步骤对我有用。

Tools -> Options -> Projects and Solutions -> Web Package Management -> External Web Tools -> 添加以下条目 C:\Program Files\nodejs -> 并将添加的内容移至顶部。

【讨论】:

    【解决方案2】:

    工具 > 选项 > 项目和解决方案 > 网络包管理 > 外部网络工具 > 将 $(PATH) 移到 $(VSInstalledExternalTools) 上方。

    【讨论】:

    • 这就是答案!
    【解决方案3】:

    对于 Visual Studio 2017,类别名称不同。取代外部网络工具,现在称为“网络包管理”

    Visual Studio 2017 External Tools npm Not working

    【讨论】:

      【解决方案4】:

      将 VS 配置为使用较新版本的节点。

      Synchronize Node.JS Install Version with Visual Studio 2015查找 Ryan Hayes 的说明

      以下是说明中的片段,以防链接失效。

      我在 Visual Studio 之外更新了 Node.JS,但由于 VS 使用自己的安装,与任何外部安装分开,您可能会遇到 node_modules 包依赖问题,其中一个版本的 npm 安装包(这使得它依赖那个版本的 Node/npm),然后你就不能在另一个版本中运行命令(它们会中断)。具体来说,我遇到了 node-sass 和 windows 绑定的问题。解决方案是将 Visual Studio 指向我已经在 Visual Studio 外部设置的 Node.JS 版本。

      1. 首先,找到您已有的 Node.js 安装并在命令行中使用。

      我在C:\Program Files (x86)\nodejs\ 安装了nodejs。

      1. 转到 Visual Studio 2015 中的工具 > 选项
      2. 在此对话框中,转到 项目和解决方案 > 外部 Web 工具以打开管理 VS 中使用的所有第 3 方工具的对话框。这就是 Node.js 所指向的地方。
      3. 在 node.js 目录路径的顶部添加一个条目,以强制 Visual Studio 改用该版本。

      【讨论】:

      • 如果有人可以保证这个答案,请发表评论,我会接受。
      • @LukePuplett 我刚刚遇到了这个问题,这个答案确实有效。
      • 我的解决方案是确保 PATH 变量位于顶部,在其他变量之前。
      猜你喜欢
      • 2017-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-25
      • 1970-01-01
      • 2021-10-30
      • 1970-01-01
      • 2018-08-14
      相关资源
      最近更新 更多