Rename
Rename the NAPI-RS project
When you need this
napi rename renames a project created by napi new or cloned from
a package template. It updates the package name, binary name, repository URL,
and related fields across package.json, Cargo.toml, the GitHub
Actions workflow, and the generated binding names, so they stay consistent.
Run it once after scaffolding, before your first release; after that, the
release pipeline (napi build → napi artifacts → napi pre-publish,
described in Release native packages) uses the new
names everywhere.
Usage
sh
# CLI
napi rename [--options]
typescript
// Programmatically
import { NapiCli } from '@napi-rs/cli'
new NapiCli().rename({
// options
})
Examples
Rename a freshly created project before publishing it under your own scope:
sh
napi rename \
--name @your-scope/cool \
--binary-name cool \
--repository https://github.com/your-name/cool.git
Change only the binary name (the *.node file names), leaving the package
name untouched:
sh
napi rename --binary-name cool-core
Rename a project whose crate is not at the repository root:
sh
napi rename --name @your-scope/cool --manifest-path ./crates/cool/Cargo.toml
Options
| Options | CLI Options | type | required | default | description |
|---|---|---|---|---|---|
| --help,-h | get help | ||||
| cwd | --cwd | string | false | process.cwd() | The working directory of where napi command will be executed in, all other paths options are relative to this path |
| configPath | --config-path,-c | string | false | Path to napi config json file | |
| packageJsonPath | --package-json-path | string | false | package.json | Path to package.json |
| npmDir | --npm-dir | string | false | npm | Path to the folder where the npm packages put |
| name | --name,-n | string | false | The new name of the project | |
| binaryName | --binary-name,-b | string | false | The new binary name *.node files |
|
| packageName | --package-name | string | false | The new package name of the project | |
| manifestPath | --manifest-path | string | false | Cargo.toml | Path to Cargo.toml |
| repository | --repository | string | false | The new repository of the project | |
| description | --description | string | false | The new description of the project |