Appearance
CLI & Build Commands
Fresh 🌱Create a project
shell
npm init neon my-project # scaffold a new Neon project
npm init neon@latest my-project # use the latest generatorProduces:
text
my-project/
├── Cargo.toml # Rust crate manifest
├── package.json # npm package manifest
├── README.md
└── src/
└── lib.rs # your Neon codeBuild
shell
npm install # installs deps and builds once
npm run build # debug build -> index.node (fast compile)
npm run build -- --release # release build -> index.node (optimized)Test from Node
shell
node
> const addon = require('.')
> addon.hello()
'hello node'Clean
shell
cargo clean # remove the Rust target/ build directoryVerify the toolchain
shell
node --version
npm --version
rustc --version
cargo --versionTargeting a Node-API version
Set the napi feature in Cargo.toml (higher = more capabilities, newer minimum Node):
toml
[dependencies.neon]
features = ["napi-6"]Add a Rust dependency
toml
# Cargo.toml
[dependencies]
num_cpus = "1"Common artifacts
| Path | What it is |
|---|---|
index.node | The compiled native module that require('.') loads. |
target/ | Rust build output. Never publish this to npm. |
Iterate on debug, ship on release
Debug builds compile quickly for a tight dev loop. Switch to --release when measuring performance or producing a published binary.