Skip to content

Instantly share code, notes, and snippets.

@aquiseb
Last active July 24, 2020 01:02
Show Gist options
  • Save aquiseb/537644d53bbb93ef2332618334dd76ed to your computer and use it in GitHub Desktop.
Save aquiseb/537644d53bbb93ef2332618334dd76ed to your computer and use it in GitHub Desktop.
Get node-sass bindings for your AWS Lambda deployment

AWS Lambda - Node-Sass

If you deployed your app to AWS Lambda with scss, you most got an error saying the node-sass bindings are missing.

Missing binding /opt/nodejs/node_modules/node-sass/vendor/linux-x64-64/binding.node\nNode Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x\n\nFound bindings for the following environments:\n - OS X 64-bit with Node.js 12.x\n\nThis usually happens because your environment has changed since running npm install.\nRun npm rebuild node-sass to download the binding for your current environment.

Solution

AWS Lambda requires linux-x64-64_binding.node. If you're coding on macOs or Windows, you won't have it. So here's the command to include in your deployment script.

curl -Lo node_modules/node-sass/vendor/linux-x64-64/binding.node https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-64_binding.node --create-dirs

Or include this in your deployment script to rebuild the "traditional way".

export SASS_BINARY_NAME=linux-x64-64&&node --eval "require('./node_modules/node-sass/scripts/install.js')"&&npm rebuild node-sass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment