How to Fix the Error Where NPM Install Fails with the node-gyp Error?

Sometimes, we run into the error Where NPM install fails with the node-gyp error.

In this article, we’ll look at how to fix the error Where NPM install fails with the node-gyp error.

Fix the Error Where NPM Install Fails with the node-gyp Error

To fix the error Where NPM install fails with the node-gyp error, we should install the Visual C++ Build Tools

To do this, run:

npm i -g windows-build-tools

This will install Python 2.7 with the build tools globally.

If we have multiple versions of the Python installed, we may have to run:

node-gyp --python /path/to/python2.7
npm config set python /path/to/executable/python2.7

to set the copy of Python interpreter to use.

The build tools comes with the latest version of Node.js, so upgrading to the latest version of Node.js is another fix for this error.

Conclusion

To fix the error Where NPM install fails with the node-gyp error, we should install the Visual C++ Build Tools

The build tools comes with the latest version of Node.js, so upgrading to the latest version of Node.js is another fix for this error.