# @commercetools-frontend/create-mc-app 中文文档

规范地址：https://npmcn.com/package/%40commercetools-frontend/create-mc-app/

版本：27\.17\.1
npm 元数据更新时间：2026-11-10T16:02:35.559Z
中文译文更新时间：2026-11-10T16:06:02.171Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40commercetools-frontend/create-mc-app
原文对照：https://npmcn.com/package/%40commercetools-frontend/create-mc-app/?lang=original
项目主页：https://docs.commercetools.com/merchant-center-customizations
源码仓库：https://github.com/commercetools/merchant-center-application-kit

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：217 kB，32 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：未声明
- Node.js 要求：^22\.23\.4 \|\| ^24\.22\.1 \|\| \>=26\.12\.1
- 运行依赖：12 个
- 首次发布：2019-01-03T11:40:47.945Z
- 最新版本发布：2026-11-10T16:02:35.112Z
- 近 30 天下载量：13825（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：1428（近 12 个月 204 个）

## 中文简介

创建Merchant Center 应用程序以快速起动并运行

## 安装

```sh
npm install @commercetools-frontend/create-mc-app
```

也可以使用：`pnpm add @commercetools-frontend/create-mc-app`、`yarn add @commercetools-frontend/create-mc-app`、`bun add @commercetools-frontend/create-mc-app`

## README

# @ commercialtools- frontend/ create- mc- app

[![Latest release (latest dist-tag)](https://badgen.net/npm/v/@commercetools-frontend/create-mc-app)](https://www.npmjs.com/package/@commercetools-frontend/create-mc-app) [![Latest release (next dist-tag)](https://badgen.net/npm/v/@commercetools-frontend/create-mc-app/next)](https://www.npmjs.com/package/@commercetools-frontend/create-mc-app) [![Minified + GZipped size](https://badgen.net/bundlephobia/minzip/@commercetools-frontend/create-mc-app)](https://bundlephobia.com/result?p=@commercetools-frontend/create-mc-app) [![GitHub license](https://badgen.net/github/license/commercetools/merchant-center-application-kit)](https://github.com/commercetools/merchant-center-application-kit/blob/main/LICENSE)

看看这个 [文档](https://docs.commercetools.com/merchant-center-customizations/api-reference/create-mc-app) 更多信息.

## 地方发展

此指南用于 **内部开发者** 想要在本地修改启动模板并测试更改而无需发布新版本.

### 如何运作

GitHub 寄存器中的 CLI 克隆模板( 不是您的本地文件系统) 。 这意味着您必须在本地测试前将模板更改推向 git 分支 .

### 先决条件

-   本地克隆仓库
-   `pnpm` 已安装
-   Git 推动访问仓库

### 工作流程

#### 1\. 修改模板

编辑模板目录中的文件 :

```bash
# For custom applications
application-templates/starter/
application-templates/starter-typescript/

# For custom views
custom-views-templates/starter/
custom-views-templates/starter-typescript/
```

#### 2\. 向一个处提交和推动

```bash
git checkout -b my-template-changes # create a new branch
git add application-templates/starter/ # do this after you make changes
git commit -m "chore(templates): add welcome header to starter template"
git push origin my-template-changes # push the changes to the new branch
```

#### 3\. 与你的分行一起运行本地CLI

从寄存器根 :

```bash
NODE_ENV=test node packages/create-mc-app/bin/cli.js my-test-app \
  --template starter \
  --template-version my-template-changes # important: use the branch name you created
```

**重要内容:** 使用相对路径( 例如 ), `my-test-app`非绝对路径(例如, `/Users/name/my-test-app`) (中文(简体) ).

#### 4\. 校验您的更改

```bash
cd my-test-app # navigate to the new app
yarn start # verify your template changes are present
```

### 快速引用

```bash
# Complete workflow
git checkout -b template-updates # create a new branch
# ... make changes to application-templates/starter/ (e.g., add a welcome message) ...
git add application-templates/starter/ # do this after you make changes
git commit -m "chore(templates): update landing page styles"
git push origin template-updates # push the changes to the new branch

cd packages/create-mc-app
pnpm build
cd ../..

NODE_ENV=test node packages/create-mc-app/bin/cli.js test-project \
  --template starter \
  --template-version template-updates

cd test-project # navigate to the new app
yarn start # verify your template changes are present
```

### 关键点

-   ✅ **必须推动更改到 git** - 模板从 GitHub 复制,而不是从本地文件系统复制
-   ✅ **使用相对路径** - 避免从绝对路径开始 `/`
-   ✅ **使用 `--template-version`** - 指定您的分支名称以测试更改
-   ✅ **不需要 npm 发布** - 直接用树枝进行试验
-   ✅ **合并前的测试** - 在合并到 `main`

### 解决问题

**错误: “ 名称包含非法字符 ”**

-   你在用一条绝对的道路 取而代之的是使用相对路径(例如, `my-app` 改为 `/Users/name/my-app`(中文(简体) )

**不反映变化的模板**

-   确保您已经将您的更改推向了 Git 分支
-   校验 `--template-version` 旗帜匹配您的分支名称

## 常见问题

### @commercetools-frontend/create-mc-app 是什么？

创建Merchant Center 应用程序以快速起动并运行

### 如何安装 @commercetools-frontend/create-mc-app？

在项目目录运行 npm install @commercetools-frontend/create-mc-app，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 create-mc-app，可以用 npx create-mc-app 直接运行。

### @commercetools-frontend/create-mc-app 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/commercetools-frontend\_\_create-mc-app 是否存在。

### @commercetools-frontend/create-mc-app 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @commercetools-frontend/create-mc-app 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js ^22\.23\.4 \|\| ^24\.22\.1 \|\| \>=26\.12\.1。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @commercetools-frontend/create-mc-app 可以商用吗？

@commercetools-frontend/create-mc-app 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @commercetools-frontend/create-mc-app 的下载量有多少？

根据 npm 官方下载统计，@commercetools-frontend/create-mc-app 在 2026/10/11 – 2026/11/09 这 30 天内被下载 13,825 次，日均约 461 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @commercetools-frontend/create-mc-app 还在维护吗？

最新版本 27\.17\.1 发布于 2026/11/11（今天）；至今共发布 1428 个版本，其中过去 12 个月发布了 204 个；首次发布于 2019/01/03。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

