Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I upgrade Libsass with npm?

I'm currently running NPM's node-sass tool, but the version of libsass it is running is 3.2.2, and the version I need to be running is 3.2.4, as this fixes a crucial bug in one of the frameworks I am using.

enter image description here

I can find no information on how to build and/or update either node-sass or libsass to meet my requirements. I am already running the latest version of node-sass, 3.1.2.

Yet, my node-sass package.json seems to have a key:value pair which indicates libsass is at 3.2.4, yet this clearly isn't correct.

What is the easiest way to upgrade my version of libsass?

Updates

6 June

I have done some additional searching, and still cannot get libsass to be at a version of 3.2.4. I have tried upgrading an older package of node-sass, and checking my environment variables for overrides. No solution yet.

7 June

It does appear that the Libsass version that is sourced by node-sass is 3.2.4, yet it is not being picked up, and is defaulting to a Libass binarypath:

path.join(__dirname, '..', 'vendor', sass.binaryName.replace(/_/, '/'));

which on my machine yields:

H:\myproj\node_modules\gulp-sass\node_modules\node-sass\vendor\win32-x64-14\binding.node

I have no idea what this means. Take a look at node-sass\lib\extensions.js on line 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();
 
like image 534
marked-down Avatar asked Jun 06 '15 10:06

marked-down


People also ask

How do I check Sass version?

To check the version, run the command: sass –version. The latest version is 1.49.


1 Answers

There is no special command for that. Take a look at the lib/extensions.js file. It has several intresting lines:

/**
 * 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 in this case is only a source folder. You can try to make a clean build. Remove node-sass and install it again.

npm install [email protected]
...
node ./node_modules/.bin/node-sass --version
node-sass   3.0.0   (Wrapper)   [JavaScript]
libsass     3.2.2   (Sass Compiler) [C/C++]  

When updating:

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++] 

P.S. Be careful with @at-root in 3.2.4. It is bugged.

Update
If it will not solve your problem, try to remove all npm cache with

npm cache clean

Second update
Try to manually install the binding:

cd node-sass
rm -r vendor
node scripts/install.js --sass-binary-site https://github.com/sass/node-sass/releases/download/

It will output something like:

Binary downloaded and installed at /Users/sobolev/Documents/github/modernizr-mixin/node_modules/node-sass/vendor/darwin-x64-14/binding.node
like image 196
sobolevn Avatar answered Sep 29 '22 14:09

sobolevn