node.js - VS Task Runner Explorer - Node Sass 找不到绑定(bind)

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

打开 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 编译正常。

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

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

卢克

最佳答案

配置 VS 以使用较新版本的 Node 。

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

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

I updated Node.JS outside of Visual Studio, but since VS uses its own install that is separate from any outside installation, you can potentially run into a node_modules package dependency issue where one version of npm installs a package (which makes it rely on that version of Node/npm), and then you can’t run commands in the other version (they break). Specifically, I had an issue with node-sass and windows bindings. The solution was to point Visual Studio to the version of Node.JS that I had already set up externally to Visual Studio.

  1. First, find the Node.js installation you already have and use at the command line.

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

  1. Go to Tools > Options in Visual Studio 2015.
  2. In this dialog, go to Projects and Solutions > External Web Tools to open the dialog that manages all of the 3rd party tools used within VS. This is where Node.js is pointed to.
  3. Add an entry at the top to the path to the node.js directory to force Visual Studio to use that version instead. enter image description here

关于node.js - VS Task Runner Explorer - Node Sass 找不到绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40846006/

相关文章:

vb.net - 如何在 vb 中选择小于 "1000"或 "n"的随机数?

visual-studio - Npm angularjs 2 - 找不到 "angular/compiler"依赖项

node.js - 如何使用 Node.js/Mongoose/MongoDB + ConnectSet 正确地进行负载平衡?

node.js - 在 sequelize 中重命名外键关联

c# - 按空格键时停止默认的自动完成行为

node.js - 为什么我必须以管理员身份调用 npm link?

javascript - '.'不被识别为在 exec() 中使用时抛出的内部或外部命令,但从命令行运行时则不会

node.js - 在nodejs中测试后台进程(使用磁带)

mysql - 在 node-mysql 中防止 SQL 注入(inject)的最佳实践是什么?

c# - 抛出异常时如何防止调试器进入我的方法?