Installation
Requirements
Section titled “Requirements”| Item | Requirement |
|---|---|
| Node.js | ≥ 16 (18 / 20 LTS recommended) — only needed for the npm installer |
| Platform | macOS Intel/Apple Silicon · Linux x64/arm64 · Windows x64/arm64 |
| Network | npm registry, plus the binary download host (Aliyun OSS by default) |
| Optional | Go toolchain, only when building from source |
The npm package is a thin wrapper: it downloads a pre-built, static Go binary
for your platform on first use and registers the sensecraft-cli command.
The binary itself has no runtime dependencies.
Install (recommended)
Section titled “Install (recommended)”Run the installer with npx:
npx @seeed-studio/sensecraft-cli installThis will:
- Download the binary matching your platform and the package version.
- Register
sensecraft-cliglobally on yourPATH. - If no credentials exist yet and you are in an interactive terminal, offer
the browser setup wizard. To use an Access Key created in the account
center instead, run
auth addafter installing (see Authentication).
Verify:
sensecraft-cli --versionsensecraft-cli --helpWindows
Section titled “Windows”node -vnpx @seeed-studio/sensecraft-cli installsensecraft-cli --version- The command is installed as
sensecraft-cli.cmdundernpm prefix -g. - If a new terminal can’t find it, add that directory to the system PATH.
- PowerShell 5+ or Windows Terminal is recommended; Git Bash usually works too.
- Some antivirus tools quarantine the first-downloaded
sensecraft-cli.exe— allow-list the install directory and reinstall if that happens.
Run without installing
Section titled “Run without installing”Every command works through npx, at the cost of a small startup check each time:
npx @seeed-studio/sensecraft-cli device listInstall a specific version
Section titled “Install a specific version”npm install -g @seeed-studio/sensecraft-cli@0.1.4Binary downloads are addressed as
{RELEASE_BASE}/v{version}/sensecraft-cli-{os}-{arch}[.exe], with the default
release base
https://sensecraft-statics.oss-us-east-1.aliyuncs.com/static/bin/sensecraft-cli.
Shell completion (optional)
Section titled “Shell completion (optional)”The CLI ships Cobra completions — tab-complete commands and flags:
# zsh (macOS: pick a directory on your $fpath)sensecraft-cli completion zsh > "${fpath[1]}/_sensecraft-cli"
# bash (Linux)sensecraft-cli completion bash | sudo tee /etc/bash_completion.d/sensecraft-cli
# fishsensecraft-cli completion fish > ~/.config/fish/completions/sensecraft-cli.fishOpen a new shell to load it. Windows: sensecraft-cli completion powershell
prints the script — add it to your $PROFILE.
sensecraft-cli: command not found
Section titled “sensecraft-cli: command not found”Confirm the install ran (npx @seeed-studio/sensecraft-cli install), then
check whether the npm global bin directory is on your PATH. The installer
tells you which directory it needs — when your PATH is missing it, its
output ends with this hint:
提示: 若无法直接运行 sensecraft-cli,请将以下目录加入 PATH: /Users/you/.npm-global/bin(“If you cannot run sensecraft-cli directly, add the following directory to PATH.”)
Adding a directory to PATH means putting one export line in your
shell’s profile file, so every new terminal starts with it.
macOS / Linux — zsh shown; use ~/.bashrc instead if your shell is
bash (echo $SHELL says which):
npm prefix -g # common values: # macOS (Homebrew Node): /opt/homebrew → bin dir /opt/homebrew/bin # Linux: ~/.npm-global → bin dir ~/.npm-global/bin
echo 'export PATH="$(npm prefix -g)/bin:$PATH"' >> ~/.zshrc # or ~/.bashrcsource ~/.zshrcnpm prefix -g prints npm’s global directory and the command lives in
its bin subdirectory — the same directory the hint shows.
Windows (PowerShell) — set it for your user, then open a new terminal:
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";" + (npm prefix -g) + "\bin", "User")Then open a new terminal — PATH changes only apply to shells started
afterwards — and run sensecraft-cli --version again.
Upgrade
Section titled “Upgrade”npm install -g @seeed-studio/sensecraft-cli@latestThe installer compares the version stamp of the downloaded binary
(vendor/.version) with the npm package version: if they match it reuses the
cached binary, otherwise it downloads the matching one. Confirm with
sensecraft-cli --version.
If the version refuses to change, clear both the package and the npm cache and reinstall:
npm uninstall -g @seeed-studio/sensecraft-clinpm cache clean --forcenpx @seeed-studio/sensecraft-cli@<target-version> installsensecraft-cli --versionUninstall
Section titled “Uninstall”npm uninstall -g @seeed-studio/sensecraft-cliThe binary under the package’s vendor/ directory is removed with it.
Credentials live outside the package — remove them separately if you are
done with the CLI on that machine:
rm -rf ~/.config/sensecraft-cli # macOS / Linux # Windows: Remove-Item -Recurse "$env:APPDATA\sensecraft-cli"Removing the config deletes the locally stored Access Keys and tokens — see Authentication for what is stored and how to remove individual profiles.
Offline, intranet and custom mirrors
Section titled “Offline, intranet and custom mirrors”Use a locally built dist/
Section titled “Use a locally built dist/”Build all platform binaries, then point the installer at them:
./script/build.sh # in a clone of the source repoexport SENSECRAFT_CLI_LOCAL_DIST="$PWD/dist"npx @seeed-studio/sensecraft-cli installPoint at a mirror
Section titled “Point at a mirror”export SENSECRAFT_CLI_RELEASE_BASE="https://your-mirror.example.com/sensecraft-cli"npx @seeed-studio/sensecraft-cli installThe mirror must reproduce the release layout:
…/sensecraft-cli/v0.1.4/sensecraft-cli-darwin-arm64…/sensecraft-cli/v0.1.4/sensecraft-cli-linux-amd64…Skip the download entirely
Section titled “Skip the download entirely”export SENSECRAFT_CLI_SKIP_DOWNLOAD=1Installation fails if vendor/ does not already contain a binary matching
the current version — useful in CI to guarantee no network access.
Verify a checksum
Section titled “Verify a checksum”If a SHA256 is published for the release:
export SENSECRAFT_CLI_SHA256="<hex digest>"The install fails when the downloaded bytes don’t match.
Proxies
Section titled “Proxies”The installer honors the standard Node/system proxy variables:
export HTTPS_PROXY=http://proxy.example.com:8080export HTTP_PROXY=http://proxy.example.com:8080Build from source
Section titled “Build from source”git clone https://github.com/Seeed-Solution/sensecraft-cli.gitcd sensecraft-cli
go build -o sensecraft-cli ../sensecraft-cli --version
# all 6 platform binaries, into dist/./script/build.shOne behavioral difference to know: a binary you built yourself reads its
config from the current directory by default, while the npm-installed CLI
reads ~/.config/sensecraft-cli/ — see
Configuration for how to unify
them with SENSECRAFT_CLI_PATH.
Verify the installation
Section titled “Verify the installation”Sandbox commands return sample JSON without touching the network — but they still need a profile to exist, so bootstrap a simulated one first (writes a fake config, no account needed):
sensecraft-cli auth init --sandbox # accept the defaults, ~20 secondssensecraft-cli device list --sandboxsensecraft-cli group list --sandboxsensecraft-cli model constants --sandboxsensecraft-cli app list --mine --sandbox(If a command has no sandbox mode it simply reports an error — that’s expected.)