Rea*_*ues 13 sass node.js node-sass libsass
我目前正在运行NPM的node-sass工具,但它运行的libsass版本是3.2.2,我需要运行的版本是3.2.4,因为这修复了我在其中一个框架中的一个关键错误使用.

我找不到有关如何构建和/或更新node-sass或libsass以满足我的要求的信息.我已经在运行最新版本的node-sass,3.1.2.
然而,我的node-sass package.json似乎有一个键:值对,表示libsass是3.2.4,但这显然是不正确的.
升级我的libsass版本的最简单方法是什么?
我做了一些额外的搜索,仍然无法使libsass处于3.2.4的版本.我已经尝试升级较旧的node-sass包,并检查我的环境变量是否有覆盖.还没有解决方案.
似乎由node-sass提供的Libsass版本是3.2.4,但它没有被拾取,并且默认为Libass binarypath:
path.join(__dirname, '..', 'vendor', sass.binaryName.replace(/_/, '/'));
Run Code Online (Sandbox Code Playgroud)
在我的机器上产生:
H:\myproj\node_modules\gulp-sass\node_modules\node-sass\vendor\win32-x64-14\binding.node
Run Code Online (Sandbox Code Playgroud)
我不知道这是什么意思.看看node-sass\lib\extensions.js第134行:
sass.getBinaryPath = function(throwIfNotExists) {
var binaryPath;
if (flags['--sass-binary-path']) {
binaryPath = flags['--sass-binary-path'];
} else if (process.env.SASS_BINARY_PATH) {
binaryPath = process.env.SASS_BINARY_PATH;
} else if (pkg.nodeSassConfig && pkg.nodeSassConfig.binaryPath) {
binaryPath = pkg.nodeSassConfig.binaryPath;
// This is the only statement that executes successfully, my libsass binary path is coming from this location. Why?
} else {
binaryPath = path.join(__dirname, '..', 'vendor', sass.binaryName.replace(/_/, '/'));
}
if (!fs.existsSync(binaryPath) && throwIfNotExists) {
throw new Error(['`libsass` bindings not found in ', binaryPath, '. Try reinstalling `node-sass`?'].join(''));
}
return binaryPath;
};
sass.binaryPath = sass.getBinaryPath();
Run Code Online (Sandbox Code Playgroud)
没有专门的命令可以做到这一点。看一下lib/extensions.js 文件。其中有几行很有趣:
/**
* The default URL can be overriden using
* the environment variable SASS_BINARY_SITE
* or a command line option --sass-binary-site:
*
* node scripts/install.js --sass-binary-site http://example.com/
*
* The URL should to the mirror of the repository
* laid out as follows:
* SASS_BINARY_SITE/
* v3.0.0
* v3.0.0/freebsd-x64-14_binding.node
* ... etc. for all supported versions and platforms
*/
Run Code Online (Sandbox Code Playgroud)
Libsass在本例中只是一个源文件夹。您可以尝试进行干净的构建。删除node-sass并重新安装。
npm install node-sass@3.0.0
...
node ./node_modules/.bin/node-sass --version
node-sass 3.0.0 (Wrapper) [JavaScript]
libsass 3.2.2 (Sass Compiler) [C/C++]
Run Code Online (Sandbox Code Playgroud)
更新时:
npm update node-sass
node ./node_modules/.bin/node-sass --version
node-sass 3.1.2 (Wrapper) [JavaScript]
libsass 3.2.4 (Sass Compiler) [C/C++]
Run Code Online (Sandbox Code Playgroud)
PS 小心@at-root使用3.2.4。它被窃听了。
更新
如果它不能解决您的问题,请尝试删除所有npm缓存
npm cache clean
Run Code Online (Sandbox Code Playgroud)
第二次更新
尝试手动安装绑定:
cd node-sass
rm -r vendor
node scripts/install.js --sass-binary-site https://github.com/sass/node-sass/releases/download/
Run Code Online (Sandbox Code Playgroud)
它会输出类似以下内容:
Binary downloaded and installed at /Users/sobolev/Documents/github/modernizr-mixin/node_modules/node-sass/vendor/darwin-x64-14/binding.node
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9832 次 |
| 最近记录: |