How can I upgrade Libsass with npm?
Asked Answered
G

3

14

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();
 
Glyndaglynias answered 6/6, 2015 at 10:23 Comment(4)
I have added a manual method. Try it out.Frustrate
Are you sure your question isn't answered here: #28409600Monandry
@cinnamon, nope. This is about libsass, a dependency of node-sass.Glyndaglynias
Do you have any progress?Frustrate
F
1

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
Frustrate answered 6/6, 2015 at 18:41 Comment(6)
Sorry, but I wasn't able to get this to work. I have checked my environment variables; there is nothing overriding the choice of libsass used, and I could not install node-sass 3.0.0 without errors. Libsass is still 3.2.2.Glyndaglynias
Have you tried to completely remove node-sass? What errors do you get?Frustrate
Yes. I have removed and installed node-sass a dozen times now, different versions, locally, globally, without success.Glyndaglynias
May be it is a cache issue? I have updated my answer.Frustrate
Hmm... doesn't appear to be. npm cache clean'd, and reinstalled both node-sass and gulp-sass. Still not working :(Glyndaglynias
Last try, installing from git: npm install this version. If nothing, try to manually download proper binding from there (win32, I guess).Frustrate
B
1

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.

Billion answered 12/6, 2015 at 17:59 Comment(0)
C
0

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 fixes.

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

Characteristically answered 12/6, 2015 at 2:17 Comment(1)
Installing the current version at time of writing gave me node-sass 3.2.0 and libsass 3.2.5. If you want to have a compatible version of libsass 3.2.4+ with your version of node-sass without doing a bunch of self maintenance, just do the upgrade now.Characteristically

© 2022 - 2024 — McMap. All rights reserved.