yarn – 永夜 https://www.shuijingwanwq.com 没有不值得去解决的问题,也没有不值得去学习的技术! Fri, 15 May 2026 13:59:30 +0000 zh-Hans hourly 1 https://wordpress.org/?v=7.0 在 Windows PowerShell 中执行 yarn 相关命令时报错:不允许使用与号(&) https://www.shuijingwanwq.com/2023/11/30/8253/ https://www.shuijingwanwq.com/2023/11/30/8253/#respond Thu, 30 Nov 2023 01:45:25 +0000 https://www.shuijingwanwq.com/?p=8253 浏览量: 256 1、在 Windows PowerShell 中执行 yarn 相关命令时报错:不允许使用与号(&)。如图1
在 Windows PowerShell 中执行 yarn 相关命令时报错:不允许使用与号(&)

图1



PS E:\wwwroot\with-blade> yarn hotishop theme build & hotishop app build --all
所在位置 行:1 字符: 27
+ yarn hotishop theme build & hotishop app build --all
+                           ~
不允许使用与号(&)。& 运算符是为将来使用而保留的;请用双引号将与号引起来("&"),以将其作为字符串的一部分传递。
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : AmpersandNotAllowed



2、决定将 & 替换为 “&”,然后执行:yarn hotishop theme build 成功后,报错:’hotishop’ 不是内部或外部命令,也不是可运行的程序或批处理文件。


PS E:\wwwroot\with-blade> yarn hotishop theme build "&" hotishop app build --all
...
@theme/brooklyn: √ Mix: Compiled successfully in 2.73m
@theme/brooklyn: webpack compiled successfully
lerna success run Ran npm script 'prod' in 1 package in 180.7s:
lerna success - @theme/brooklyn
Done in 288.18s.
'hotishop' 不是内部或外部命令,也不是可运行的程序
或批处理文件。


3、在第 2 个 hotishop 之前添加 yarn ,最后两个 build 皆成功运行。如图2
在第 2 个 hotishop 之前添加 yarn ,最后两个 build 皆成功运行

图2



PS E:\wwwroot\with-blade> yarn hotishop theme build "&" yarn hotishop app build --all
yarn run v1.22.15
$ E:\wwwroot\with-blade\node_modules\.bin\hotishop theme build
~ Removing apps from "./themes/brooklyn/apps/internal" ...
$ E:\wwwroot\with-blade\node_modules\.bin\lerna run --scope @theme/brooklyn prod
lerna notice cli v6.6.2
...
@theme/brooklyn: √ Mix: Compiled successfully in 2.80m
@theme/brooklyn: webpack compiled successfully
lerna success run Ran npm script 'prod' in 1 package in 216.7s:
lerna success - @theme/brooklyn
Done in 253.16s.
yarn run v1.22.15
$ E:\wwwroot\with-blade\node_modules\.bin\hotishop app build --all
$ E:\wwwroot\with-blade\node_modules\.bin\lerna run --scope @extension/* prod
lerna notice cli v6.6.2
lerna info versioning independent
lerna notice filter including "@extension/*"
lerna info filter [ '@extension/*' ]
lerna info Executing command in 28 packages: "yarn run prod"
@extension/back-top: $ mix --production
...
lerna success - @extension/visitors-counter
√ Done!
Done in 770.26s.


]]>
https://www.shuijingwanwq.com/2023/11/30/8253/feed/ 0
执行 yarn 命令时,报错:The engine “node” is incompatible with this module. https://www.shuijingwanwq.com/2023/11/02/8164/ https://www.shuijingwanwq.com/2023/11/02/8164/#respond Thu, 02 Nov 2023 01:54:46 +0000 https://www.shuijingwanwq.com/?p=8164 浏览量: 149 1、执行 yarn 命令时,报错:The engine “node” is incompatible with this module.Expected version “^14.18.0 || ^16.14.0 || >=18.0.0”. Got “16.13.1”。如图1
执行 yarn 命令时,报错:The engine "node" is incompatible with this module.Expected version "^14.18.0 || ^16.14.0 || >=18.0.0". Got "16.13.1"

图1



PS E:\wwwroot\shopify-app>yarn create @shopify/app
yarn create v1.22.15
[1/4] Resolving packages...
[2/4] Fetching packages...
error execa@7.2.0: The engine "node" is incompatible with this module. Expected version "^14.18.0 || ^16.14.0 || >=18.0.0". Got "16.13.1"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.


2、^16.14.0相当于>=16.14.0,<16.15,决定重新安装 Node.js 的 16 的最新版本。打开网址:https://nodejs.org/dist/latest-v16.x/ 计划下载 node-v16.20.2-x64.msi 。但是,发现其不符合版本依赖的要求。如图2
^16.14.0相当于>=16.14.0,<16.15,决定重新安装 Node.js 的 16 的最新版本。打开网址:https://nodejs.org/dist/latest-v16.x/ 计划下载 node-v16.20.2-x64.msi 。但是,发现其不符合版本依赖的要求

图2

  3、>=18.0.0 也是可行的,最张决定下载 18 的最新版本。下载 node-v18.18.0-x64.msi。再次执行 yarn 命令时,不再报错。如图3
>=18.0.0 也是可行的,最张决定下载 18 的最新版本。下载 node-v18.18.0-x64.msi。再次执行 yarn 命令时,不再报错

图3



PS E:\wwwroot\shopify-app> node -v
v18.18.0
PS E:\wwwroot\shopify-app> yarn create @shopify/app
yarn create v1.22.15
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "@shopify/create-app > @oclif/core > ts-node@10.9.1" has unmet peer dependency "@types/node@*".
warning "@shopify/create-app > @oclif/core > ts-node@10.9.1" has unmet peer dependency "typescript@>=2.7".
[4/4] Building fresh packages...
success Installed "@shopify/create-app@3.49.3" with binaries:
      - create-app

Welcome. Let’s get started by naming your app project. You can change it later.

?  Your project name?
>  fruitful-shareholder-app
   ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


]]>
https://www.shuijingwanwq.com/2023/11/02/8164/feed/ 0
在 Laravel 6 中,安装 Laravel Mix 时(npm install),报错:npm ERR! ERESOLVE unable to resolve dependency tree https://www.shuijingwanwq.com/2023/06/20/7747/ https://www.shuijingwanwq.com/2023/06/20/7747/#respond Tue, 20 Jun 2023 01:28:32 +0000 https://www.shuijingwanwq.com/?p=7747 浏览量: 85 1、在 Laravel 6 中,安装 Laravel Mix 时(npm install),报错:npm ERR! ERESOLVE unable to resolve dependency tree。如图1
在 Laravel 6 中,安装 Laravel Mix 时(npm install),报错:npm ERR! ERESOLVE unable to resolve dependency tree

图1



PS E:\wwwroot\object> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: postcss@8.3.1
npm ERR! node_modules/postcss
npm ERR!   dev postcss@"8.3.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer postcss@"^8.3.11" from laravel-mix@6.0.39
npm ERR! node_modules/laravel-mix
npm ERR!   dev laravel-mix@"^6.0.31" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\Lenovo\AppData\Local\npm-cache\_logs\2023-05-19T07_21_41_833Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Lenovo\AppData\Local\npm-cache\_logs\2023-05-19T07_21_41_833Z-debug-0.log


2、发现程序根目录下存在:yarn.lock,替换为:yarn 命令,不再报错。如图2
发现程序根目录下存在:yarn.lock,替换为:yarn 命令,不再报错

图2



PS E:\wwwroot\object> yarn
yarn install v1.22.15
[1/4] Resolving packages...
[2/4] Fetching packages...


]]>
https://www.shuijingwanwq.com/2023/06/20/7747/feed/ 0
error Couldn’t find a package.json file in “E:\\wwwroot\\shopify-theme-app-extension\\20221012” info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. https://www.shuijingwanwq.com/2022/10/27/7112/ https://www.shuijingwanwq.com/2022/10/27/7112/#respond Thu, 27 Oct 2022 01:23:17 +0000 https://www.shuijingwanwq.com/?p=7112 浏览量: 126 1、执行:yarn shopify app generate extension 时,报错:error Couldn’t find a package.json file in “E:\\wwwroot\\shopify-theme-app-extension\\20221012” info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.。如图1
执行:yarn shopify app generate extension 时,报错:error Couldn't find a package.json file in "E:\\wwwroot\\shopify-theme-app-extension\\20221012" info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

图1



PS E:\wwwroot\shopify-theme-app-extension\20221012> yarn shopify app generate extension
yarn run v1.22.15
error Couldn't find a package.json file in "E:\\wwwroot\\shopify-theme-app-extension\\20221012"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.


2、参考:https://classic.yarnpkg.com/en/docs/cli/init 。以交互方式创建或更新 package.json 文件。执行:yarn init。如图2
参考:https://classic.yarnpkg.com/en/docs/cli/init 。以交互方式创建或更新 package.json 文件。执行:yarn init

图2



PS E:\wwwroot\shopify-theme-app-extension\20221012> yarn init
yarn init v1.22.15
question name (20221012):
question version (1.0.0):
question description: 20221012
question entry point (index.js):
question repository url:
question author: Qiang Wang
question license (MIT):
question private:
success Saved package.json
Done in 39.35s.


3、查看生成的 package.json 文件


{
  "name": "20221012",
  "version": "1.0.0",
  "description": "20221012",
  "main": "index.js",
  "author": "Qiang Wang",
  "license": "MIT"
}



4、报错:error Couldn’t find a package.json file 已经消失。


PS E:\wwwroot\shopify-theme-app-extension\20221012> yarn shopify app generate extension
yarn run v1.22.15
error Command "shopify" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.


5、参考:使用 Shopify CLI 构建主题应用扩展:https://www.shuijingwanwq.com/2022/10/25/7106/。]]>
https://www.shuijingwanwq.com/2022/10/27/7112/feed/ 0
lerna ERR! yarn run prod exited 1 in ‘@theme/object’ error Command failed with exit code 1. https://www.shuijingwanwq.com/2022/08/29/6901/ https://www.shuijingwanwq.com/2022/08/29/6901/#respond Mon, 29 Aug 2022 06:01:56 +0000 https://www.shuijingwanwq.com/?p=6901 浏览量: 208 1、lerna ERR! yarn run prod exited 1 in ‘@theme/object’ error Command failed with exit code 1.。如图1
lerna ERR! yarn run prod exited 1 in '@theme/object' error Command failed with exit code 1.

图1



$ E:\wwwroot\object\node_modules\.bin\lerna run --scope @theme/object prod
lerna notice cli v5.1.8
lerna info versioning independent
lerna notice filter including "@theme/object"
lerna info filter [ '@theme/object' ]
lerna info Executing command in 1 package: "yarn run prod"
@theme/object: $ mix --production
@theme/object: i Compiling Mix
@theme/object: √ Mix: Compiled with some errors in 2.41m
@theme/object: ERROR in E:\wwwroot\object\packages\types\index.ts
@theme/object: 8:8-16
@theme/object: [tsl] ERROR in E:\wwwroot\object\packages\types\index.ts(8,9)
@theme/object:       TS2451: Cannot redeclare block-scoped variable '__data__'.
@theme/object: ERROR in E:\wwwroot\object\packages\types\index.ts
@theme/object: 13:8-17
@theme/object: [tsl] ERROR in E:\wwwroot\object\packages\types\index.ts(13,9)
@theme/object:       TS2451: Cannot redeclare block-scoped variable '__asset__'.
@theme/object: webpack compiled with 2 errors
@theme/object: error Command failed with exit code 1.
@theme/object: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! yarn run prod exited 1 in '@theme/object'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Done in 573.86s.


2、决定删除掉目录:node_modules ,重新执行 yarn、yarn prod 命令。]]>
https://www.shuijingwanwq.com/2022/08/29/6901/feed/ 0
执行 yarn 时,报错:Failed to apply patch for package laravel-mix. This happened because the patch file patches\laravel-mix+6.0.43.patch could not be parsed. https://www.shuijingwanwq.com/2022/07/06/6752/ https://www.shuijingwanwq.com/2022/07/06/6752/#respond Wed, 06 Jul 2022 01:14:40 +0000 https://www.shuijingwanwq.com/?p=6752 浏览量: 323 1、执行 yarn 时,报错:Failed to apply patch for package laravel-mix.This happened because the patch file patches\laravel-mix+6.0.43.patch could not be parsed.。如图1
执行 yarn 时,报错:Failed to apply patch for package laravel-mix.This happened because the patch file patches\laravel-mix+6.0.43.patch could not be parsed.

图1



PS E:\wwwroot\object> yarn
yarn install v1.22.15
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
$ patch-package
patch-package 6.4.7
Applying patches...
concat@1.0.3 ✔
eslint-plugin-jsonc@2.3.0 ✔

**ERROR** Failed to apply patch for package laravel-mix

  This happened because the patch file patches\laravel-mix+6.0.43.patch could not be parsed.

  If you just upgraded patch-package, you can try running:

    cd patches\laravel-mix+6.0.43.patc
    patch -p1 -i h
    npx patch-package laravel-mix
    cd ../..

  Otherwise, try manually creating the patch file again.

  If the problem persists, please submit a bug report:

    https://github.com/ds300/patch-package/issues/new?title=Patch+file+parse+error&body=%3CPlease+attach+the+patch+file+in+question%3E


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.


2、查看 Git 日志,patches\laravel-mix+6.0.43.patch 的上一个版本是:patches\laravel-mix+6.0.48.patch。如图2
查看 Git 日志,patches\laravel-mix+6.0.43.patch 的上一个版本是:patches\laravel-mix+6.0.48.patch

图2

3、删除掉目录:node_modules 后,再次执行:yarn,仍然报同样的错误。如图3
删除掉目录:node_modules 后,再次执行:yarn,仍然报同样的错误

图3

4、参考提示,执行:npx patch-package laravel-mix。如图4
参考提示,执行:npx patch-package laravel-mix

图4



PS E:\wwwroot\object> npx patch-package laravel-mix
patch-package 6.4.7
• Creating temporary folder
• Installing laravel-mix@6.0.43 with yarn
• Diffing your files with clean files
⁉️  Not creating patch file for package 'laravel-mix'
⁉️  There don't appear to be any changes.
npm notice
npm notice New minor version of npm available! 8.1.2 -> 8.12.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.12.1
npm notice Run npm install -g npm@8.12.1 to update!
npm notice


5、再次执行:yarn,仍然报错。参考:https://github.com/ds300/patch-package/issues/191 。将换行符从 CRLF 替换为 LF。不再报错。如图5
再次执行:yarn,仍然报错。参考:https://github.com/ds300/patch-package/issues/191 。将换行符从 CRLF 替换为 LF。不再报错。

图5

]]>
https://www.shuijingwanwq.com/2022/07/06/6752/feed/ 0