docs/docs/en/api/cli/source/download.md
Fetch NocoBase from npm, Docker, or Git. --version is shared by all three source types: npm uses a package version, Docker uses an image tag, and Git uses a git ref.
nb source download [flags]
| Parameter | Type | Description |
|---|---|---|
--yes, -y | boolean | Use defaults and skip interactive prompts |
--verbose | boolean | Show verbose command output |
--locale | string | CLI prompt language: en-US or zh-CN |
--source, -s | string | Source type: docker, npm, or git |
--version, -v | string | npm package version, Docker image tag, or Git ref |
--replace, -r | boolean | Replace the target directory if it already exists |
--dev-dependencies, -D / --no-dev-dependencies | boolean | Whether npm/Git installs devDependencies |
--output-dir, -o | string | Download target directory, or directory for the Docker tarball |
--git-url | string | Git repository URL |
--docker-registry | string | Docker image repository name without tag |
--docker-platform | string | Docker image platform: auto, linux/amd64, or linux/arm64 |
--docker-save / --no-docker-save | boolean | Whether to save the pulled Docker image as a tarball |
--npm-registry | string | Registry used for npm/Git downloads and dependency installation |
--build / --no-build | boolean | Whether to build after npm/Git dependency installation |
--build-dts | boolean | Whether to generate TypeScript declaration files during npm/Git build |
--hook-script | string | Hook module to run after npm scaffold or Git clone and before dependency installation; only applies to npm/Git source |
nb source download
nb source download -y --source npm --version alpha
nb source download -y --source npm --version alpha --no-build
nb source download --source npm --version alpha --output-dir=./app
nb source download --source docker --version alpha --docker-registry=nocobase/nocobase --docker-platform=linux/arm64
nb source download -y --source docker --version alpha --docker-save -o ./docker-images
nb source download --source git --version alpha [email protected]:nocobase/nocobase.git
nb source download --source git --version fix/cli-v2
nb source download -y --source npm --version alpha --build-dts
nb source download -y --source npm --version alpha --npm-registry=https://registry.npmmirror.com
nb source download -y --source git --version beta --hook-script ./hooks.mjs
--hook-script only affects the current nb source download run. If you want the hook to be saved with the env and reused by nb app upgrade or local source restore, pass it through nb init --hook-script instead.
The hook file must default-export an object with beforeDependencyInstall(context):
export default {
beforeDependencyInstall: async ({ sourcePath, version, envConfig }) => {
// Runs after git clone / npm scaffold and before yarn install.
},
};
When you run nb source download --hook-script directly, beforeDependencyInstall receives context.phase as source-download and context.command as source:download. This command does not run beforeAppInstall or afterAppStart; those hooks belong to app install, start, restart, and upgrade flows.
With Git source, common dist-tags are resolved to branches: latest -> main, beta -> next, alpha -> develop.