Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node-gyp build how to specify target node version while building node extension

I am migrating from node-waf build to node-gyp build system for node native addons. node-gyp says it supports multiple target version, but I couldn't find how to specify target node version while using node-gyp.

Problem is, my system has node v0.10.3 installed, but I need to build my native addon for node version 0.8.20. When I build the add-on it uses the headers for v0.10.3, which ofcourse gives errors.

I can't find how can I specify the node version while configuring / building using node-gyp.

Please help.

like image 959
Rahul Shukla Avatar asked Apr 12 '13 06:04

Rahul Shukla


People also ask

How do I change node to specific version?

Or if you want a specific version like I needed 8.0. 0 then you can do this using. node -v. If you want to switch to the different version of Node, just type n in the terminal and you should see the Node versions listed.

What version of Python does node-gyp need?

node-gyp requires that you have installed a compatible version of Python, one of: v3. 7, v3. 8, v3. 9, or v3.

What file does node-gyp read the build?

gyp file describes the configuration to build your module, in a JSON-like format. This file gets placed in the root of your package, alongside package. json .

Why do I need node-gyp?

node-gyp is a tool that enables the compilation of native add-on modules for Node in multiple platforms. It has widespread use and is included as a dependency in many NPM packages. On most systems, this isn't an issue, and installing node-gyp with the rest of your packages works as expected.


1 Answers

The solution is to specify --target argument while configuring using node-gyp. for ex.

node-gyp --arch=<WHATEVER> --target=v0.8.20 configure
like image 110
Rahul Shukla Avatar answered Oct 02 '22 20:10

Rahul Shukla