Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get yarn install --offline with node-sass working?

I am trying to use yarn in offline mode because the build server I am using does not have access to yarn registry or github.com.

I found this article on how to use yarn in offline mode which works great until I added node-sass.

It appears even if you use yarn install --offline, node-sass will go to github.com to download libsass.

Is there a way to instruct node-sass to use an offline version of libsass instead of going to github.com?

like image 310
null_pointer Avatar asked Jul 31 '17 19:07

null_pointer


People also ask

How do you install Sass yarn?

You can install Sass globally using npm install -g sass which will provide access to the sass executable. You can also add it to your project using npm install --save-dev sass . This provides the executable as well as a library: const sass = require('sass'); const result = sass.

Should I use Sass or node sass?

For smaller or typical Sass projects, Dart-Sass(JS) is perfect, it's easy to install without any external binding dependencies like node-sass. If your sass files take time to compile and if Node-Sass supports all the features you used, then go with Node-Sass!

Is node Sass deprecated?

Warning: LibSass and Node Sass are deprecated. While they will continue to receive maintenance releases indefinitely, there are no plans to add additional features or compatibility with any new CSS or Sass features. Projects that still use it should move onto Dart Sass.

How do you add yarn globally?

The global command makes executables available to use on your operating system. Note: Unlike the --global flag in npm, global is a command which must immediately follow yarn . Entering yarn add global package-name will add the packages named global and package-name locally instead of adding package-name globally.


1 Answers

As @jonrsharpe pointed out, you need to use either --sass-binary-site, --sass-binary-name or --sass-binary-path to to tell node-sass where to find libsass. In my case I ended up using sass-binary-path.

So the first thing I did was download the Windows version of libsass here. I downloaded the _binding.node version because I assumed the _binding.pdb version is a debugging file.

I my case I created a .yarnrc that looks like the below:

yarn-offline-mirror "////sharedrive//folder"
yarn-offline-mirror-pruning true
sass-binary-path "////sharedrive//folder//win32-ia32-47_binding.node"

With the Windows version all / needed to be escaped with //. sass-binary-path needed the libsass binary at the end which in the above case is win32-ia32-47_binding.node.

So with all that everything worked great.

like image 62
null_pointer Avatar answered Oct 15 '22 16:10

null_pointer