Skip to content

Instantly share code, notes, and snippets.

@rurumimic
Created October 3, 2023 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rurumimic/d97a7dbf253f9c35b13485a860da696c to your computer and use it in GitHub Desktop.
Save rurumimic/d97a7dbf253f9c35b13485a860da696c to your computer and use it in GitHub Desktop.
Build Node.js

Node

Build

export CC="ccache clang"
export CXX="ccache clang++"
./configure --ninja --debug
make -j4

for compile_commands.json:

make clean
bear -- make -j4

Debug Node

if [ ! -r node_g ] || [ ! -L node_g ]; then ln -fs out/Debug/node node_g; fi

Install

make install PREFIX=/opt/node-debug/
/opt/node-debug/
├── bin
│   ├── corepack -> ../lib/node_modules/corepack/dist/corepack.js
│   ├── node
│   ├── npm -> ../lib/node_modules/npm/bin/npm-cli.js
│   └── npx -> ../lib/node_modules/npm/bin/npx-cli.js
├── include
│   └── node
├── lib
│   └── node_modules
└── share
    ├── doc
    └── man

Run

./bin/node

Welcome to Node.js v21.0.0-pre.
Type ".help" for more information.

> console.log("Hello, World!");
Hello, World!
undefine

Ctrl+D to exit the REPL

Source Code

vi src/node_main.cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment