@adobe/aem-cli

中文文档
16.22.16发布于 2026/10/28Apache-2.0ES Module构建来源已验证近 30 天下载 3.1万

AEM CLI

原始使用文档
文档目录18 节
  1. Status
  2. Installation
  3. Quick Start
  4. Starting development
  5. automatically open the browser
  6. browser console log forwarding
  7. html folder for content preview
  8. setting up a self-signed cert for using https
  9. environment
  10. Starting an import
  11. Managing content
  12. Local content serving
  13. Testing
  14. Browser Injectables
  15. aem up fails with unable to get local issuer certificate
  16. Option 1: Using IT-provided CA certificate
  17. Option 2: Extracting certificate from browser
  18. npm install fails with File exists: /opt/homebrew/bin/hlx

AEM Command Line Interface (aem)

Status

codecov GitHub Actions Workflow Status GitHub license GitHub issues

The AEM Command Line Interface allows web developers to create, develop, and deploy digital experiences using the Adobe Experience Manager Sites feature Edge Delivery Services. Some of this functionality was known as Franklin or Project Helix before.

Installation

Install aem as a global command. You need Node 12.11 or newer.

npm install -g @adobe/aem-cli

If this fails with File exists: /opt/homebrew/bin/hlx, please see here.

Quick Start

$ aem --help
Usage: aem <command> [options]

Commands:
  aem up       Run a AEM development server
  aem import   Run the AEM import server
  aem content  Manage local da.live content

Options:
  --version                Show version number                         [boolean]
  --log-file, --logFile    Log file (use "-" for stdout)  [array] [default: "-"]
  --log-level, --logLevel  Log level
        [string] [choices: "silly", "debug", "verbose", "info", "warn", "error"]
                                                               [default: "info"]
  --tls-key, --tlsKey      Path to .key file (for enabling TLS)        [string]
  --tls-cert, --tlsCert    Path to .pem file (for enabling TLS)        [string]
  --help                   Show help                                   [boolean]

use <command> --help to get command specific details.

for more information, find our manual at https://github.com/adobe/helix-cli

Starting development

$ cd <my-cool-project>
$ aem up

automatically open the browser

The --open argument takes a path, eg --open=/products/, will cause the browser to be openend at the specific location. Disable with --no-open'.

browser console log forwarding

The --forward-browser-logs flag enables forwarding of browser console messages (log, error, warn, info) to the terminal. This is particularly useful for debugging client-side issues without having to open the browser's developer tools.

$ aem up --forward-browser-logs

When enabled, browser console messages will appear in your terminal with the following format:

[Browser:error] 2025-07-27T10:30:45.123Z http://localhost:3000/script.js:42 Error message here

This feature is especially helpful when:

  • Debugging JavaScript errors in a headless environment
  • Monitoring client-side behavior during development
  • Working with AI coding assistants that need visibility into both server and client logs

html folder for content preview

The --html-folder option enables serving HTML files without extensions, useful for previewing content changes when you don't have access to the authoring system.

$ aem up --html-folder drafts                      # serves at /drafts/*
$ aem up --html-folder html --html-mount /       # serves at /* (root)
$ aem up --html-folder drafts --html-mount /preview # serves at /preview/*

Use --html-mount to control the URL path where files are served. Without it, files are served at /FOLDER/*.

This enables two features:

  1. Extension-less URLs: Access /drafts/page (or /page with root mount) to serve the corresponding .html file
  2. Plain HTML with metadata: Create .plain.html files that are automatically wrapped with proper HTML structure and metadata processing

Plain HTML files (.plain.html)

Plain HTML files contain only the main content and an optional metadata block. The CLI automatically:

  • Wraps content in <html><head><body><header><main><footer> structure
  • Merges in head.html content
  • The metadata block is removed from the rendered content and converted to meta tags in the <head>.

When a request resolves to <stem>, the CLI looks up <stem>.html first and falls back to <stem>.plain.html. Pass --preferPlainHtml to reverse this order — useful when you keep both files side-by-side and want the plain version to win:

$ aem up --html-folder drafts --preferPlainHtml

setting up a self-signed cert for using https

  1. create the certificate
$ openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out server.crt -keyout server.key -subj "/CN=localhost"

this will create 2 files: server.crt and server.key

Alternatively, if your browser does not trust the certificate, you can use mkcert to generate a trusted certificate:

# Install mkcert via Homebrew or your preferred method, then run:
mkcert -cert-file server.crt -key-file server.key localhost 127.0.0.1
  1. start aem with tls support
$ aem up --tls-cert server.crt --tls-key server.key
    ___    ________  ___                          __      __ v14.26.1
   /   |  / ____/  |/  /  _____(_)___ ___  __  __/ /___ _/ /_____  _____
  / /| | / __/ / /|_/ /  / ___/ / __ `__ \/ / / / / __ `/ __/ __ \/ ___/
 / ___ |/ /___/ /  / /  (__  ) / / / / / / /_/ / / /_/ / /_/ /_/ / /
/_/  |_/_____/_/  /_/  /____/_/_/ /_/ /_/\__,_/_/\__,_/\__/\____/_/

info: Starting AEM dev server v14.26.1
info: Local AEM dev server up and running: https://localhost:3000/
  1. (optional) Add arguments to .env file:
$ echo -e "AEM_TLS_CERT=server.crt\nAEM_TLS_KEY=server.key" >> .env

environment

All the command arguments can also be specified via environment variables. the .env file is loaded automatically.

example:

.env

AEM_OPEN=/products
AEM_PORT=8080
AEM_PAGES_URL=https://stage.myproject.com

HTTP Proxy

In order to use a HTTP proxy (eg behind a corporate firewall), you can set the respective environment variables:

NO_PROXY is a list of host names (optionally with a port). If the input URL matches any of the entries in NO_PROXY, then the input URL should be fetched by a direct request (i.e. without a proxy).

Matching follows the following rules:

NO_PROXY=* disables all proxies. Space and commas may be used to separate the entries in the NO_PROXY list. If NO_PROXY does not contain any entries, then proxies are never disabled. If a port is added after the host name, then the ports must match. If the URL does not have an explicit port name, the protocol's default port is used. Generally, the proxy is only disabled if the host name is an exact match for an entry in the NO_PROXY list. The only exceptions are entries that start with a dot or with a wildcard; then the proxy is disabled if the host name ends with the entry. See test.js for examples of what should match and what does not.

*_PROXY The environment variable used for the proxy depends on the protocol of the URL. For example, https://example.com uses the "https" protocol, and therefore the proxy to be used is HTTPS_PROXY (NOT HTTP_PROXY, which is only used for http:-URLs).

If present, ALL_PROXY is used as fallback if there is no other match.

Global

optionvariabledefaultdescription
--log-fileAEM_LOG_FILE-Log file. use - to log to stdout
--log-levelAEM_LOG_LEVELinfoLog level

Up command

optionvariabledefaultdescription
--portAEM_PORT3000Development server port
--addrAEM_ADDR127.0.0.1Development server bind address
--livereloadAEM_LIVERELOADtrueEnable automatic reloading of modified sources in browser.
--no-livereloadAEM_NO_LIVERELOADfalseDisable live-reload.
--forward-browser-logsAEM_FORWARD_BROWSER_LOGSfalseForward browser console logs to terminal.
--html-folderAEM_HTML_FOLDERundefinedServe HTML files from folder without extensions.
--html-mountAEM_HTML_MOUNT/FOLDERURL path where html-folder files are served.
--prefer-plain-htmlAEM_PREFER_PLAIN_HTMLfalsePrefer <stem>.plain.html over <stem>.html when both exist.
--openAEM_OPEN/Open a browser window at specified path after server start.
--no-openAEM_NO_OPENfalseDisable automatic opening of browser window.
--tls-keyAEM_TLS_KEYundefinedPath to .key file (for enabling TLS)
--tls-certAEM_TLS_CERTundefinedPath to .pem file (for enabling TLS)

In Git worktrees, the default port is derived from the branch name (3000-3999) to reduce conflicts between worktrees. An explicit --port or AEM_PORT setting (including in .env) overrides this automatic selection, even when set to 3000. Command-line options take precedence over environment variables.

Starting an import

The AEM Importer is an application that supports importing content to AEM.

$ cd <my-cool-project>
$ aem import

Read the full AEM Importer documentation.

Managing content

The aem content commands let you check out content from da.live locally, make bulk edits, and push changes back. The local content lives in a content/ folder in your project.

CommandDescription
aem content cloneClone da.live content locally into content/
aem content statusShow locally added, modified, and deleted content files
aem content diffShow diff between local and remote content
aem content mergeMerge remote content into local files
aem content addStage changes in content/ (like git add)
aem content commitCommit staged changes in content/ (like git commit)
aem content pushPush committed content/ changes to da.live (use content add & content commit first)

Local content serving

When a content/ folder is present, aem up automatically serves content from it first, falling back to the proxy for any files not found locally. HTML files in content/ are wrapped with head.html and have their metadata blocks processed, so pages render the same way they would when served from da.live.

Developing AEM CLI

Testing

You can use npm run check to run the tests and check whether your code adheres to the aem-cli coding style.

Browser Injectables

Browser-injected scripts (LiveReload and console log forwarding) are maintained in a separate sub-project at packages/browser-injectables/. This isolation keeps browser testing dependencies separate from the main CLI.

Development

  • Injectable scripts are in packages/browser-injectables/src/
  • No build step required - scripts are used directly
  • Browser tests run only when injectable code changes

Testing Browser Injectables

cd packages/browser-injectables
npm install
npm test

Troubleshooting

aem up fails with unable to get local issuer certificate

This error occurs when the server certificate is not trusted by Node.js. The typical cause is that connections to the server *.aem.page and *.hlx.page are intercepted by an enterprise proxy or firewall which is trying to inspect the traffic.

These proxies use a private certificate authority (CA) to sign the certificates of the servers they intercept. To make Node.js trust the server certificate, you need to add the CA certificate to the list of trusted CAs.

Option 1: Using IT-provided CA certificate

The CA certificate is typically provided by your IT department. You can ask them for the CA certificate and save it to a file, e.g. my-ca.crt.

Then you can use the NODE_EXTRA_CA_CERTS environment variable to make Node.js trust the CA certificate:

export NODE_EXTRA_CA_CERTS=my-ca.crt
aem up

Option 2: Extracting certificate from browser

If you don't have access to the CA certificate from your IT department, you can extract it directly from your browser:

  1. Access the AEM admin URL in your browser (e.g., https://admin.hlx.page/sidekick/owner-name/repo-name/github-branch-name/config.json)
  2. Click on the padlock icon in the address bar and view the certificate details
  3. Export the certificate chain as a Base64 encoded .pem file
  4. Save it to a directory (e.g., certs/hlx.page.pem)
  5. Set the environment variable and run aem:
export NODE_EXTRA_CA_CERTS=./certs/hlx.page.pem
aem up

On Windows, use set instead of export:

set NODE_EXTRA_CA_CERTS=./certs/hlx.page.pem
aem up

Either approach will make Node.js trust the server certificate and aem up should work.

npm install fails with File exists: /opt/homebrew/bin/hlx

If you try to install @adobe/aem-cli:

> npm install -g @adobe/aem-cli
...
npm error EEXIST: file already exists
npm error File exists: /opt/homebrew/bin/hlx
npm error Remove the existing file and try again, or run npm

This can happen when you previously had installed this tool under its old package name @adobe/helix-cli. Starting with version 15.0.0, this tool was renamed aem and published as @adobe/aem-cli. The previous @adobe/helix-cli has been deprecated. However, the new package still provides the command line binary under the old name hlx in addition to aem, for backwards compatibility, which can lead to the npm install error.

To solve, first uninstall the old version, then install again with the new name:

npm uninstall -g @adobe/helix-cli
npm install -g @adobe/aem-cli

版本与发布记录

@adobe/aem-cli 共发布 318 个版本,首次发布于 2023/09/30;过去 12 个月发布了 117 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
16.22.16latest2026/10/2810 天前
16.22.152026/10/2711 天前
16.22.142026/10/2315 天前
16.22.132026/10/2117 天前
16.22.122026/10/1919 天前
16.22.112026/10/1919 天前

关于 @adobe/aem-cli 的常见问题

@adobe/aem-cli 是什么?

AEM CLI

如何安装 @adobe/aem-cli?

在项目目录运行 npm install @adobe/aem-cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 aem、hlx,可以用 npx aem 直接运行。

@adobe/aem-cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/adobe__aem-cli 是否存在。

@adobe/aem-cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@adobe/aem-cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@adobe/aem-cli 可以商用吗?

@adobe/aem-cli 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@adobe/aem-cli 的下载量有多少?

根据 npm 官方下载统计,@adobe/aem-cli 在 2026/10/05 – 2026/11/03 这 30 天内被下载 30,938 次,日均约 1,031 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adobe/aem-cli 还在维护吗?

最新版本 16.22.16 发布于 2026/10/28(10 天前);至今共发布 318 个版本,其中过去 12 个月发布了 117 个;首次发布于 2023/09/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。