Back to Napi Rs

Build

cli/docs/build.md

1.0.06.8 KB
Original Source

Build

This file is generated by cli/codegen. Do not edit this file manually.

Build the NAPI-RS project

Usage

sh
# CLI
napi build [--options]
typescript
// Programatically
import { NapiCli } from '@napi-rs/cli'

new NapiCli().build({
  // options
})

Options

OptionsCLI Optionstyperequireddefaultdescription
--help,-hget help
target--target,-tstringfalseBuild for the target triple, bypassed to cargo build --target
cwd--cwdstringfalseThe working directory of where napi command will be executed in, all other paths options are relative to this path
manifestPath--manifest-pathstringfalsePath to Cargo.toml
configPath--config-path,-cstringfalsePath to napi config json file
packageJsonPath--package-json-pathstringfalsePath to package.json
targetDir--target-dirstringfalseDirectory for all crate generated artifacts, see cargo build --target-dir
outputDir--output-dir,-ostringfalsePath to where all the built files would be put. Default to the crate folder
platform--platformbooleanfalseAdd platform triple to the generated nodejs binding file, eg: [name].linux-x64-gnu.node
jsPackageName--js-package-namestringfalsePackage name in generated js binding file. Only works with --platform flag
constEnum--const-enumbooleanfalseWhether generate const enum for typescript bindings
jsBinding--jsstringfalsePath and filename of generated JS binding file. Only works with --platform flag. Relative to --output-dir.
noJsBinding--no-jsbooleanfalseWhether to disable the generation JS binding file. Only works with --platform flag.
dts--dtsstringfalsePath and filename of generated type def file. Relative to --output-dir
dtsHeader--dts-headerstringfalseCustom file header for generated type def file. Only works when typedef feature enabled.
noDtsHeader--no-dts-headerbooleanfalseWhether to disable the default file header for generated type def file. Only works when typedef feature enabled.
dtsCache--dts-cachebooleanfalsetrueWhether to enable the dts cache, default to true
esm--esmbooleanfalseWhether to emit an ESM JS binding file instead of CJS format. Only works with --platform flag.
strip--strip,-sbooleanfalseWhether strip the library to achieve the minimum file size
release--release,-rbooleanfalseBuild in release mode
verbose--verbose,-vbooleanfalseVerbosely log build command trace
bin--binstringfalseBuild only the specified binary
package--package,-pstringfalseBuild the specified library or the one at cwd
profile--profilestringfalseBuild artifacts with the specified profile
crossCompile--cross-compile,-xbooleanfalse[experimental] cross-compile for the specified target with cargo-xwin on windows and cargo-zigbuild on other platform
useCross--use-crossbooleanfalse[experimental] use cross instead of cargo
useNapiCross--use-napi-crossbooleanfalse[experimental] use @napi-rs/cross-toolchain to cross-compile Linux arm/arm64/x64 gnu targets.
watch--watch,-wbooleanfalsewatch the crate changes and build continuously with cargo-watch crates
features--features,-Fstring[]falseSpace-separated list of features to activate
allFeatures--all-featuresbooleanfalseActivate all available features
noDefaultFeatures--no-default-featuresbooleanfalseDo not activate the default feature