I have lots of projects that use grunt-sass
, which depends on node-sass
, which depends on libsass
. Everytime I checkout one of those projects from the their git repository and npm install
them, libsass
is compiled again and in my computer, this process takes a lot of time.
node-sass
has ways of providing an existing libsass
binary, so I don't have to go through the process of compiling it everytime. (https://github.com/sass/node-sass#binary-configuration-parameters)
I tried then installing globally a node-sass
npm package. It compiles libsass and install it in my /usr/local/lib/node_modules/node-sass
folder:
npm install -g node-sass
after I set a sass_binary_path
parameter in my ~/.npmrc
file:
sass_binary_path=/usr/local/lib/node_modules/node-sass/vendor/darwin-x64-47/binding.node
When I npm install
my projects after checkout them, libsass isn't compiled anymore and the installation is successful. But when I execute a grunt task which uses grunt-sass, here's what I get:
Loading "sass.js" tasks...ERROR
>> Error: ENOENT: no such file or directory, scandir '~/dev/my-project/node_modules/node-sass/vendor'
Warning: Task "sass:dist" not found. Use --force to continue.
Aborted due to warnings.
What am I doing wrong in this process of caching libsass
?
--
EDIT:
When I install npm install
using the normal process, node_modules/node-sass/vendor/darwin-x64-47/binding.node is created. When I try to use the node-sass cache flags, it doesn't even create the node_modules/node-sass/vendor
folder.
I was able to use a cached node-sass
library finally.
First a binary package should be downloaded from: https://github.com/sass/node-sass/releases
Then I used a environment variable to point to this binary.
export SASS_BINARY_PATH="$HOME/dev/bin/darwin-x64-47_binding.node"
When installing node-sass with npm, it uses the provided binary.