Skip to content

Instantly share code, notes, and snippets.

@bellbind
Last active August 20, 2020 03:10
Show Gist options
  • Save bellbind/d558ca401cae46ef1dca to your computer and use it in GitHub Desktop.
Save bellbind/d558ca401cae46ef1dca to your computer and use it in GitHub Desktop.
[nodejs]How to use your custom build binaries of nodejs

Custom nodejs build howto

TLDR:

  • How to make "custom" nodejs build
  • How to use custom build node via nvm
  • How to use custom build npm for native packages

What is "custom" build

  • "custom" build is a local binary archive

    • set "DISTTYPE=custom" with "make" command
  • For trying the comming version of node with npm

    • to check safely building our native packages

Build nodejs custom binary packages

(refresh the repository)

$ cd $NODE_REPO
$ make distclean
$ git checkout master
$ git pull

build custom binary archives

$ ./configure --with-intl=full-icu --download=all
$ make -j4 DISTTYPE=custom CUSTOMTAG=pre BUILD_INTL_FLAGS=--with-intl=full-icu binary
$ make DISTTYPE=custom CUSTOMTAG=pre BUILD_INTL_FLAGS=--with-intl=full-icu  tar-headers

(Not only "pre", any name is available to CUSTOMTAG.)

then the files generated as:

  • node-v6.0.0-pre-darwin-x64.tar.gz
  • node-v6.0.0-pre-headers.tar.gz
    • the headers archive is required for building native packages

Install them to your nvm manually

extract the custom binary to inside nvm

$ cd ~/.nvm/versions/node
$ tar xf $NODE_REPO/node-v6.0.0-pre-darwin-x64.tar.gz
$ mv node-v6.0.0-pre-darwin-x64 v6.0.0-pre

reopen terminal shell to find "v6.0.0-pre" at nvm ls

$ nvm ls
$ nvm use v6.0.0-pre
$ node -e "console.log(process.versions)"

Build native packages with the custom npm

use npm with --nodedir option as:

$ npm install --nodedir=$NODE_REPO install iconv

Build native pakcages with the custom npm using a remote dist server

(In the case, CUSTOMTAG=bb instread of pre because CUSTOMTAG=pre npm cannot accept the disturl)

set up files for a dist server

  • to serve the custom headers.tar.gz and its SHASUMS256.txt
$ mkdir v6.0.0-bb/
$ cd v6.0.0-bb/
$ cp $NODE_REPO/node-v6.0.0-bb-headers.tar.gz ./
$ shasum -a 256 *.gz > SHASUMS256.txt
$ cd ../

start as http server like:

$ python3 -mhttp.server

(the http server started at port 8000)

Then use npm on other machines. e.g.:

$ npm install --disturl=http://thedistserver:8000 install iconv
@bellbind
Copy link
Author

bellbind commented Mar 7, 2016

NOTE:

node-v6.0.0 required nan >= 2.2.0 (failed to compile at nan.h of both nan-2.0.9 and nan-2.1.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment