Why Use node-gyp Command in Node.js
node-gyp is a tool with cross-platform supported used by the Chromium team. This tool special design in Node.js for creating native addon modules. node-gyp is also supported all of the node target versions like 0.8, …., 4, 5, 6, etc. It automatically downloads important files for target version.
1. node-gyp is very easy to use with consistent interface
2. In every platform build a module with a single command.
3. Supports number of target versions of Node
Installation Command node-gyp in Node.js
Install node-gyp with npm basic of Node command line as given bellow
$ npm install -g node-gyp
Note: Basic use of node-gyp is to control the internal process of C++ compilation. This module designed for node.js addons. If you move to a different system may be work but at the time use different Os not work.
How to Fix node-gyp Error on Windows
Sometimes use npm command on window error occur like Failed at the <package>@<version> install script ‘node-gyp rebuild’ at that time use a PowerShell CLI instance with administrative privileges and use the below code:
npm install –global –production windows-build-tools
Commands of node-gyp
build:- This command is used to builds the native addon.
install:- Installs files for the used version.
clean:- If you want to remove Removes directory after build use this.
rebuild:- Configure and build the project.
remove:- For Removes header files
configure:- If you want to generate project after build use configure command.
help:- For display help dialog
We hope this article helped you to understand How To Generate Your Project With The Native Addon In node.js With node-gyp Command. You may also want to see How To Speed Up Your Website With Google JQuery CDN?