[英]How can I upgrade Libsass with npm?
我目前正在運行NPM的node-sass工具,但它運行的libsass版本是3.2.2,我需要運行的版本是3.2.4,因為這修復了我在其中一個框架中的一個關鍵錯誤使用。
我找不到有關如何構建和/或更新node-sass或libsass以滿足我的要求的信息。 我已經在運行最新版本的node-sass,3.1.2。
然而,我的node-sass package.json
似乎有一個key:value對,表示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(/_/, '/'));
在我的機器上產生:
H:\myproj\node_modules\gulp-sass\node_modules\node-sass\vendor\win32-x64-14\binding.node
我不知道這是什么意思。 看看第134行的node-sass\\lib\\extensions.js
:
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();
沒有特別的命令。 看一下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
*/
在這種情況下, 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++]
更新時:
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++]
PS在3.2.4
注意@at-root
。 它被竊聽了 。
更新
如果它無法解決您的問題,請嘗試刪除所有npm
緩存
npm cache clean
第二次更新
嘗試手動安裝綁定:
cd node-sass
rm -r vendor
node scripts/install.js --sass-binary-site https://github.com/sass/node-sass/releases/download/
它將輸出如下內容:
Binary downloaded and installed at /Users/sobolev/Documents/github/modernizr-mixin/node_modules/node-sass/vendor/darwin-x64-14/binding.node
你能嘗試以下步驟:
這應該可以解決您的問題。
node-sass 3.2.0的最新版本說
這個版本使Libsass陷入3.2.5,帶來了一堆修復。
npm install node-sass
現在將安裝一個帶有libsass> = 3.2.5的node-sass。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.