打开 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.
- First, find the Node.js installation you already have and use at the command line.
我在 C:\Program Files (x86)\nodejs\
安装了 nodejs。
- Go to Tools > Options in Visual Studio 2015.
- 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.
- Add an entry at the top to the path to the node.js directory to force Visual Studio to use that version instead.
关于node.js - VS Task Runner Explorer - Node Sass 找不到绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40846006/