Trying to install an app with node-sass on WSL. Getting "gyp ERR! stack Error: `make` failed with exit code: 2"

Trying to install an app with node-sass on WSL. Getting "gyp ERR! stack Error: `make` failed with exit code: 2"

October 10, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Trying to install an app with node-sass on WSL. Getting "gyp ERR! stack Error: `make` failed with exit code: 2"

Solving Node-Sass Installation Issues on WSL

As an experienced developer working with Linux-based systems like Windows Subsystem for Linux (WSL), I frequently encounter challenges while setting up environments for modern web applications. One of the most common issues users face is when trying to install dependencies using tools like npm or yarn, particularly when they involve native add-ons like node-sass.

Recently, a developer reached out with an issue related to installing node-sass on WSL, specifically for a Magento storefront application:

make: Leaving directory '/mnt/c/Github/psp-storefront-magento2/node_modules/node-sass/build'
make: *** [binding.target.mk:133: Release/obj.target/binding/src/binding.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2

This error usually occurs when the build process for node-sass fails during installation, likely due to compatibility issues between your system’s setup and the package requirements.

Understanding the Problem

The key points to note from the provided log:

  • The issue arises during the make step of the compilation process.
  • It suggests a problem with the build target or dependencies required for node-sass.
  • The error message hints at a failure in building the binding object file.

Troubleshooting Steps

To troubleshoot this issue effectively, follow these best practices:

1. Check Your System Configuration

Ensure that your WSL environment is configured correctly and has all necessary prerequisites installed. For node-sass to build properly, you need to have the appropriate toolchain (like GCC) and development libraries available.

2. Update npm and Node.js

Outdated versions of npm or Node.js can often cause compatibility issues with packages like node-sass. Make sure your system is running the latest stable versions by using:

npm install -g npm@latest
nvm install node

3. Clean Up and Reinstall

Sometimes, corrupt lock files or cached data can lead to installation failures. You can clean up your project’s dependencies and reinstall them:

  1. Delete the node_modules directory.
  2. Remove the yarn.lock or package-lock.json file (depending on which package manager you’re using).
  3. Run npm install or yarn install again to reinstall all packages.

4. Use a Different Package Manager

If you’re experiencing issues with npm, consider switching to yarn for managing your project’s dependencies:

npm install -g yarn
yarn install

Conclusion

Resolving build errors like the one mentioned often involves a combination of checking system configuration, updating tools, and cleaning up cached data. In this case, ensure that your WSL environment is properly set up with the necessary toolchain and development libraries.

Remember to always keep your Node.js version and package managers updated for better compatibility with modern packages. If you’re still experiencing issues after following these steps, consider reaching out to the project maintainers or seeking community support on platforms like GitHub or StackOverflow.

For more in-depth guides on setting up development environments using WSL, be sure to check out our comprehensive tutorials at Laravel Company. We cover various aspects of Linux system setup and optimization for efficient web application development.

Magento 2 Extensions Configuration Errors

Our network