@enact/cli

中文文档
7.4.0发布于 2026/11/09Apache-2.0CommonJS近 30 天下载 6194

Full-featured build environment tool for Enact applications.

原始使用文档
文档目录13 节
  1. Installation
  2. Creating a new App
  3. Available Commands
  4. enact serve (aliased as npm run serve )
  5. enact pack (aliased as npm run pack , npm run pack-p , and …
  6. enact clean (aliased as npm run clean )
  7. enact lint (aliased as npm run lint )
  8. enact test (aliased as npm run test and npm run test-watch )
  9. enact license (aliased as npm run license )
  10. Enact Build Options
  11. Displaying Lint Output in the Editor
  12. Documentation
  13. Copyright and License Information

@enact/cli Travis NPM

A standalone toolkit for rapid Enact app development.

Installation

All that's needed to install @enact/cli is to use npm to install it globally. For Linux sudo may be required.

npm install -g @enact/cli

Note: Node 16 or greater required.

Creating a new App

The only time you're ever want to directly use the Enact CLI is when you want to create a new project.

enact create [directory]

This will generate a basic App template, complete with npm scripts and dependencies. If no directory path is specified, it will be generated within the working directory.

Advanced: If you've used npm link on separate installations of the Enact repo, you can run enact link afterwards to link in any available Enact libraries.

Available Commands

Enact supports several commands, each accessible through the enact command and through npm aliases in package.json. For help on individual commands, add --help following the command name. The commands are:

enact serve (aliased as npm run serve)

Builds and serves the app in the development mode.
Open http://localhost:8080 to view it in the browser.

The page will reload if you make edits.

enact pack (aliased as npm run pack, npm run pack-p, and npm run watch)

Builds the project in the working directory. Specifically, pack builds in development mode with code un-minified and with debug code included, whereas pack-p builds in production mode, with everything minified and optimized for performance. Be sure to avoid shipping or performance testing on development mode builds.

enact clean (aliased as npm run clean)

Deletes previous build fragments from ./dist.

enact lint (aliased as npm run lint)

Runs the Enact configuration of ESLint on the project for syntax analysis.

enact test (aliased as npm run test and npm run test-watch)

These tasks will execute all valid tests (files that end in -specs.js) that are within the project directory. The test is a standard single execution pass, while test-watch will set up a watcher to re-execute tests when files change.

enact license (aliased as npm run license)

Outputs a JSON representation of the licenses for modules referenced by the current project as well as any licenses of modules used by @enact/cli that may be included in a production build of an app.

Enact Build Options

The @enact/cli tool will check the project's package.json looking for an optional enact object for a few customization options:

  • template [string] - Filepath to an alternate HTML template to use with the Webpack html-webpack-plugin.
  • isomorphic [string] - Alternate filepath to a custom isomorphic-compatible entry point. Not needed if main entry point is already isomorphic-compatible.
  • title [string] - Title text that should be put within the HTML's <title></title> tags. Note: if this is a webOS-project, the title will, by default, be auto-detected from the appinfo.json content.
  • alias [object] - String mapping of webpack alias paths to use when building.
  • theme [object] - A simplified string name to extrapolate fontGenerator, ri, and screenTypes preset values from. For example, "limestone".
  • fontGenerator [string] - Filepath to a CommonJS fontGenerator module which will build locale-specific font CSS to inject into the HTML. By default, will use any preset for a specified theme or fallback to limestone.
  • ri [object] - Resolution independence options to be forwarded to the postcss-resolution-independence. By default, will use any preset for a specified theme or fallback to limestone.
    • baseSize [number] - The root font-size to use when converting the value of the base unit to a resolution-independent unit. For example, when baseSize is set to 24, 48px in the LESS file will be converted to 2rem.
  • screenTypes [array|string] - Array of 1 or more screentype definitions to be used with prerender HTML initialization. Can alternatively reference a json filepath to read for screentype definitions. By default, will use any preset for a specified theme or fallback to limestone.
  • nodeBuiltins [object] - Configuration settings for polyfilling NodeJS built-ins. See node webpack option.
  • resolveFallback [object] - Configuration settings for redirecting module requests when normal resolving fails. See resolve.fallback webpack option.
  • externalStartup [boolean] - Flag whether to externalize the startup/update js that is normally inlined within prerendered app HTML output.
  • forceCSSModules [boolean] - Flag whether to force all LESS/CSS to be processed in a modular context (not just the *.module.css and *.module.less files).
  • deep [string|array] - 1 or more JavaScript conditions that, when met, indicate deeplinking and any prerender should be discarded.
  • target [string|array] - A build-type generic preset string (see target webpack option) or alternatively a specific browserslist array of desired targets.
  • publicUrl [string] - Public path URL at which the app is served or destined to be hosted. This can also be set via the package.json homepage field.
  • proxy [string] - Proxy target during project serve to be used within the http-proxy-middleware.

For example:

{
    ...
    "enact": {
        "theme": "limestone",
        "resolveFallback": {
            fs: false,
            net: false,
            tls: false
        }
    }
    ...
}

Displaying Lint Output in the Editor

Some editors, including Visual Studio Code, Sublime Text, and Atom provide plugins for ESLint.

They are not required for linting. You should see the linter output right in your terminal. However, if you prefer the lint results to appear right in your editor, there are some extra steps you can do.

You would need to install an ESLint plugin for your editor first.

Ever since ESLint 6, global installs of ESLint configs are no longer supported. To work around this new limitation, while still supporting in-editor linting, we've created a new eslint-config-enact-proxy package. The eslint-config-enact-proxy acts like a small proxy config, redirecting ESLint to use a globally-installed Enact ESLint config. eslint-config-enact-proxy needs to be installed locally on a project to enable in-editor linting:

npm install --save-dev eslint-config-enact-proxy

Also, you need to modify eslintConfig property in package.json:

  "eslintConfig": {
    "extends": "enact-proxy"
  },

NOTE: For strict mode, use "extends": "enact-proxy/strict".

In order for in-editor linting to work with our updated ESLint config, you'll need to upgrade to ESLint 7 or later. This can be installed globally by running:

npm install -g eslint

Then, you will need to uninstall any previous globally-installed Enact linting package (everything but eslint itself):

npm uninstall -g eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-babel @babel/eslint-parser eslint-plugin-jest eslint-plugin-enact eslint-config-enact

Documentation

Unless otherwise specified, all content, including all source code files and documentation files in this repository are:

Copyright (c) 2016-2025 LG Electronics

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Portions of this project are based upon create-react-app, Copyright (C) 2016-present Facebook, Inc.

版本与发布记录

@enact/cli 共发布 95 个版本,首次发布于 2017/12/22;过去 12 个月发布了 10 个版本。

版本发布日期距今
7.4.0latest2026/11/094 天前
7.3.42026/08/212 个月前
7.3.32026/07/074 个月前
7.3.22026/06/234 个月前
7.3.12026/06/015 个月前
7.2.3latest-7.22026/05/046 个月前

其他发布通道:legacy → 3.0.8,production → 4.1.8,next → 7.0.0-rc.1,latest-7.2 → 7.2.3。

关于 @enact/cli 的常见问题

@enact/cli 是什么?

Full-featured build environment tool for Enact applications.

如何安装 @enact/cli?

在项目目录运行 npm install @enact/cli,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@babel/core(^8.0.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 enact,可以用 npx enact 直接运行。

@enact/cli 支持 TypeScript 吗?

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

@enact/cli 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@enact/cli 需要什么版本的 Node.js?

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

@enact/cli 可以商用吗?

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

@enact/cli 的下载量有多少?

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

@enact/cli 还在维护吗?

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