What is node-gyp
node-gyp
is a tool which compiles Node.js Addons. Node.js Addons are native Node.js Modules, written in C or C++, which therefore need to be compiled on your machine. After they are compiled with tools like node-gyp, their functionality can be accessed via require()
, just as any other Node.js Module.
If you do what you suggested the module won't work, you will need to compile it/build it with node-gyp on the system you moved the program to.
node-gyp
: https://github.com/nodejs/node-gyp
Node.js Addons: https://nodejs.org/api/addons.html
Related videos on Youtube
selftaught91
Hi my name is Raj Ranjan from Mumbai, India and I am a Full Stack developer who specializes in both web and mobile development.My core strength lies in providing quality web services, bug free, with in timeline and estimation. I have a 5+ years of experience in web technologies and 2+ years of experience in mobile technologies. Currently I am working as a senior software engineer in Research & Development of Alepo Technologies Mumbai.
Updated on August 25, 2020Comments
-
selftaught91 over 3 years
Can anyone explain me what is
node-gyp
and why it uses my system files to build Node.JS packages.- If Ii build a node project and it used
node-gyp
internally. - Then I just tar that project and moved to a different system
- I untar it there and try to use it
Will this approach work?
-
slebetman over 7 yearsIt's described on its github page: github.com/nodejs/node-gyp. Basically,
node-gyp
is likemake
. It's a tool used to control the compilation process of C++ projects. Only, it's designed specifically for node.js addons (modules written in C++). So moving to a different system may work if it uses the same CPU. Moving to a different OS or CPU (for example from x86 to ARM) won't work. For Linux, moving to a different distro of different version of the same distro may or may not work. I'm not 100% sure if moving to a different version of node.js would work -
Kzqai about 4 yearsWhen I run
yarn why node-gyp
it comes back with: becausenode-sass
, so I'm sure it has other uses, but it may be in your project if you or someone you love has been diagnosed withsass
. -
Lukas Liesis about 4 years@slebetman moving to different node version won't work, not sure if that's 100% true, yet from my experience, you need to remove old node-gyp after upgrading nodejs version and during modules install it's re-build automatically in the background.
-
Alper over 2 yearsWhy is it always broken?
- If Ii build a node project and it used
-
PirateApp over 5 yearsgotta admit, i see a module no npmjs that uses node-gyp I usually run 10 miles away
-
Jim Aho over 5 yearsIt's exciting that you nowadays can clone a (what seems) relatively simple web app written in NodeJS, and all of a sudden you must download software to compile native coden written in C and C++. The best part is when you run into problems, and you know exactly what do with your web design skills to solve this.
-
Mr-Programs over 5 yearsso you can basically use node-gyp to run ANY c/c++ code? is this transformed to javascript or executed as it is and connected through a binding?
-
vuza over 5 years@Mr-Programs It is connected through a binding, which also needs to be written by you
-
Adam Tolley over 4 years@JimAho Ideally, and often, the code is just black-boxed. The good is that you can use fast and well supported tools to do specific things like parse xml, and not have to wait for a js port which might be slower or more broken. That said, I prefer native js whenever possible, but I'm not certain that position is well founded. Also, C/C++ should be very portable for any case that is not purposefully OS dependent (like notifications). Furthermore, bug prone packages don't see wide adoption regardless of the source of said bugs.
-
Tom over 4 yearsFYI, I believe "gyp" is short for "generate your projects"
-
Timo almost 3 years@PirateApp I do not understand, can you please explain in other words? Your comment is high in rep, so I want to know it - you do not like
node-gyp
and run away? -
PirateApp almost 3 yearsnode-gyp creates native dependencies and making it work on an external environment like docker or a virtual machine seems like a pain, take bcrypt.js it certainly works much faster if you use the native one but due to it being a pain, i switched to bcryptjs that doesnt require node-gyp
-
jiajianrong about 2 yearsGood answer. Still one thing bothers me: why the ealier Java says 'write once run everywhere', but the nodejs still uses C/C++ add-ons?
-
MetaSean almost 2 years@jiajianrong - Well, you sort of answered your own question, Java's claim was 'write once run everywhere'. JavaScript, i.e. the "js" in "node.js" never made such a claim. JavaScript was initially designed to add interactivity to a specific browser (i.e. Netscape) but became the defacto language for all browser activity. nodejs brought that language to environments other than browsers, and in doing so, it is clearly going to have to interact with those additional environments. node-gyp is an attempt to provide some cross-environment compatibility.