Search code examples
javascriptnode.jsreactjsnpmnode-gyp

Does node-gyp come with npm?


The issue I am facing is npm install locally doesn't give much output with npm v6.14.9 but when deploying to server it gives some meaningless output like

gyp info spawn args ['some properties about Release']
make: entering directory 'directory'

and then goes tonns of output about node-gyp and .cpp files which does not exist in my project. My goal is to remove those outputs. Just FYI installation always successful.


Solution

  • node-gyp is a vital part of npm.

    Some npm packages come with native, not Javascript, code inside them. node-gyp's task is to compile that code and make it available for use on your machine. The code has to be compiled because the package author doesn't know whether you'll run your code on MacOs, Windows, Linux, or whatever OS, and the runnable code differs between those systems.

    node-gyp isn't a lightweight tool. It needs python and the C++ toolchain. But, if you use a package that needs it, you need it. lzma-native is one such package. Various image-handling packages also need it.

    If you don't want to use node-gyp you must remove the package that uses it from your project.

    It's good your npm install is successful. If it weren't you would have a challenging troubleshooting task ahead of you.

    Pro tip think of your nodejs project as flowers scattered in a river. The flowers are your code, and the river is your packages, the nodejs runtime, and the browsers you use. "Hey, this is wet! I want it dry." is usually not a helpful way of understanding things.