You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Node.js 18.12.1和Yarn 3.3.0创建Shopify应用失败求助

问题:Yarn 3.3.0创建Shopify PHP应用失败

使用Node.js 18.12.1搭配Yarn 3.3.0执行yarn create @shopify/app命令创建Shopify应用时失败,但切换到Yarn 1.22版本可正常完成创建。操作过程及报错信息如下:

hope@hope-Inspiron-N5050:/opt/lampp/htdocs/shopify/$ yarn create @shopify/app
➤ YN0000: ┌ Resolution step
➤ YN0032: │ keytar@npm:7.9.0: Implicit dependencies on node-gyp are discouraged
➤ YN0032: │ node-addon-api@npm:4.3.0: Implicit dependencies on node-gyp are discouraged
➤ YN0061: │ @npmcli/move-file@npm:2.0.1 is deprecated: This functionality has been moved to @npmcli/fs
➤ YN0000: └ Completed in 20s 239ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0s 957ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ keytar@npm:7.9.0 must be built because it never has been before or the last one failed
➤ YN0000: └ Completed in 6s 502ms
➤ YN0000: Done with warnings in 28s 116ms


Welcome. Let’s get started by naming your app. You can change it later.
✔ Your app's name? · yarn3
✔ Which template would you like to use? · php
✔ Downloaded template from https://github.com/Shopify/shopify-app-template-php#cli_three
✔ App initialized
  ✔ Liquid parsed
  ✔ Updated package.json
❯ Installing dependencies with yarn
  ✔ Installed dependencies in /
  ✖ Command failed with exit code 1: yarn install
    Usage Error: The nearest package directory (/tmp/abbdef41d78e306ae681b1ae…
    - If /tmp/abbdef41d78e306ae681b1aec35a1b70/app isn't intended to be a pro…
    - If /tmp/abbdef41d78e306ae681b1aec35a1b70/app is intended to be a projec…
    - Finally, if /tmp/abbdef41d78e306ae681b1aec35a1b70/app is fine and you i…
    $ yarn install [--json] [--immutable] [--immutable-cache] [--check-cache]…
◼ Clean up
◼ Initializing a Git repository...

── external error ──────────────────────────────────────────────────────────────

Error coming from `yarn install`

Command failed with exit code 1: yarn install
Usage Error: The nearest package directory
(/tmp/abbdef41d78e306ae681b1aec35a1b70/app/web/frontend) doesn't seem to be part
 of the project declared in /tmp/abbdef41d78e306ae681b1aec35a1b70/app.

- If /tmp/abbdef41d78e306ae681b1aec35a1b70/app isn't intended to be a project,
remove any yarn.lock and/or package.json file there.
- If /tmp/abbdef41d78e306ae681b1aec35a1b70/app is intended to be a project, it
might be that you forgot to list web/frontend in its workspace configuration.
- Finally, if /tmp/abbdef41d78e306ae681b1aec35a1b70/app is fine and you intend
web/frontend to be treated as a completely separate project (not even a
workspace), create an empty yarn.lock file in it.

$ yarn install [--json] [--immutable] [--immutable-cache] [--check-cache]
[--inline-builds] [--mode #0]

解决方法

方法1:临时切换到Yarn 1.x版本

Yarn 3的工作区机制与1.x差异较大,Shopify PHP模板暂未完全适配Yarn 3。执行以下命令切换到经典版Yarn:

yarn set version classic

完成应用创建后,可通过yarn set version berry切回Yarn 3.x版本。

方法2:补全项目工作区配置

若坚持使用Yarn 3,创建中断后进入生成的项目根目录,修改根目录的package.json,添加工作区配置将web/frontend纳入项目:

{
  "workspaces": [
    "web/frontend"
  ]
}

保存后在项目根目录执行yarn install完成依赖安装。

方法3:手动初始化前端目录

进入项目的web/frontend子目录,创建空的yarn.lock文件:

touch web/frontend/yarn.lock

返回项目根目录再次执行yarn install即可完成依赖安装。

内容的提问来源于stack exchange,提问作者Binaya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 06:45:37