Home » Nodejs » How can I upgrade Libsass with npm?

How can I upgrade Libsass with npm?

Posted by: admin November 30, 2017 Leave a comment


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?


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:


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();

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:
 *  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.

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


Can you try below steps:

  1. git clone https://github.com/sass/node-sass.git
  2. cd node-sass
  3. git checkout tags/v3.1.2
  4. npm install . -g
  5. node-sass -v

This should fix your problem.


The latest release of node-sass 3.2.0 says

This release bumps Libsass to 3.2.5 which brings with it a bunch of

npm install node-sass will install now install a node-sass with a libsass >= 3.2.5.