ant binary. You do not need a separate tool. The table below lists every available command; the sections that follow document each one in detail.
| Command | Alias | Summary |
|---|---|---|
init | — | Create a new package.json |
install | i | Install dependencies from the lockfile |
update | up | Re-resolve dependencies and refresh the lockfile |
add | a | Add a package to dependencies |
remove | rm | Remove a package from dependencies |
trust | — | Run lifecycle scripts for packages |
run | — | Run a script from package.json |
exec | x | Run a command from node_modules/.bin |
why | explain | Show why a package is installed |
info | — | Show package information from the registry |
ls | list | List installed packages |
cache | — | Manage the package cache |
create | — | Scaffold a project from a template |
Typical workflow
Here is the standard sequence for bootstrapping and running an Ant project:ant init writes package.json, ant add hono resolves and installs the package from the npm registry and writes ant.lockb, and ant run start executes the start script defined in package.json.
init
Creates a new package.json in the current directory. If a terminal is attached, Ant prompts you for a package name, version, and entry point. If stdin is not a TTY (for example in a CI script), it uses sensible defaults derived from the directory name.
ant init in a directory named my-app with no TTY produces:
package.json
install
Alias: i
Installs all packages listed in package.json. If ant.lockb is present, Ant uses the exact versions recorded there. If no lockfile exists, Ant resolves versions from the semver ranges in package.json and creates one.
Install packages globally to
~/.ant/pkg/global instead of the local node_modules.Save the package as a
devDependency (only applies when package names are also provided).ant install to add them:
When you pass package names to
ant install, the behavior is identical to ant add. The dedicated ant add command is preferred for clarity.update
Alias: up
Re-resolves all dependencies from their semver ranges in package.json and writes a refreshed ant.lockb. Use this when you want to pick up newer patch or minor versions within the declared ranges.
add
Alias: a
Adds one or more packages to your project, resolves the full dependency tree, installs to node_modules, and updates both package.json and ant.lockb.
Package name, optionally with a version specifier:
hono, hono@4.12.9, hono@^4.Save to
devDependencies instead of dependencies.Install globally to
~/.ant/pkg/global. Binaries are linked to ~/.ant/bin.Save to
devDependencies instead of dependencies.Install globally to
~/.ant/pkg/global. Binaries are linked to ~/.ant/bin.remove
Alias: rm
Removes one or more packages from package.json, uninstalls them from node_modules, and refreshes ant.lockb.
The name of the package to remove.
Remove from global packages at
~/.ant/pkg/global.trust
Some npm packages define postinstall or other lifecycle scripts. Ant does not run these automatically — you must explicitly trust a package before its scripts execute. This prevents supply-chain attacks from silently running arbitrary code after install.
One or more package names to trust and run lifecycle scripts for.
Trust and run lifecycle scripts for all packages that have pending scripts.
ant trust <pkg>, Ant adds the package name to a trustedDependencies field in package.json so subsequent installs run its scripts automatically.
run
Runs a named script from the scripts field in package.json. Pass -- before any extra arguments you want forwarded to the script.
The script name as defined in
package.json.exec
Alias: x
Runs a binary from node_modules/.bin. If the binary is not installed locally, Ant searches the global package directory and, if still not found, temporarily downloads the package from the registry and executes it.
The binary name to execute.
Run the binary with
ant as the interpreter instead of the system’s default node-compatible runner.antx binary is a shorthand for ant x:
why
Alias: explain
Shows which packages in the dependency tree depend on a given package. Reads from ant.lockb, so you must have a lockfile already.
The package name to explain.
info
Fetches and displays metadata for a package from the npm registry: description, license, dependency count, dist tags, tarball URL, integrity hash, and maintainers.
Package name, optionally with a version specifier.
ls
Alias: list
Lists the direct dependencies installed in the current project, along with their resolved versions.
List globally installed packages from
~/.ant/pkg/global.cache
Manages the local package cache stored at ~/.ant/pkg. The cache speeds up installs by avoiding redundant registry fetches and tarball downloads.
Subcommands
ant cache info
ant cache info
Shows the cache location, number of cached packages, total size on disk, and database size.Example output:
ant cache prune [days]
ant cache prune [days]
Removes packages from the cache that have not been accessed in more than
days days. Defaults to 30 days if no argument is given.ant cache sync
ant cache sync
Flushes any pending writes and synchronizes the cache database to disk.
create
Scaffolds a new project from an npm template package or a GitHub repository.
Either a short template name (Ant prepends
create- and runs it via ant x) or a org/repo GitHub path.Destination directory. Defaults to the repository or template name.
- npm template
- GitHub repo
For npm-style templates, Ant runs
ant x create-<template> with the remaining arguments. This is equivalent to npx create-<template>.