lenna run build命令失败。

发布于 2025-02-13 22:42:10 字数 1052 浏览 0 评论 0原文

并且在root package.json.json中有以下脚本

"scripts": {
    "build": "lerna run build",
},
"husky": {
    "hooks": {
      "pre-commit": "lint-staged",
    }
  },

react monorepo ,

module.exports = {
  '**/*.*': 'yarn build',
};

我正在研究 有以下错误:

✖ yarn build:
ERR! lerna Unknown arguments: /Users/xyz/lint-staged.config.js, /Users/xyz/package.json
error Command failed with exit code 1.
$ lerna run build /Users/xyz/lint-staged.config.js /Users/xyz/package.json
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
husky > pre-commit hook failed (add --no-verify to bypass)

在MonorePo包装夹中,package.json包含脚本如下: 软件包/webapp/package.json

"scripts": {
    "build": "run-s clean compile",
    "clean": "rm -rf *.tsbuildinfo & rm -rf build && rm -rf tmp",
    "compile": "run-p compile:*",
}

我们不能在绒毛阶段运行构建命令,还是我的实现中缺少某些内容?

谢谢

I am working on a React monorepo and I have the below scripts in the root package.json:

"scripts": {
    "build": "lerna run build",
},
"husky": {
    "hooks": {
      "pre-commit": "lint-staged",
    }
  },

lint-staged.config.js

module.exports = {
  '**/*.*': 'yarn build',
};

When I commit the code, the commit fails with the below error:

✖ yarn build:
ERR! lerna Unknown arguments: /Users/xyz/lint-staged.config.js, /Users/xyz/package.json
error Command failed with exit code 1.
$ lerna run build /Users/xyz/lint-staged.config.js /Users/xyz/package.json
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
husky > pre-commit hook failed (add --no-verify to bypass)

In the monorepo packages folder, the package.json contains the scripts as below:
package/webApp/package.json

"scripts": {
    "build": "run-s clean compile",
    "clean": "rm -rf *.tsbuildinfo & rm -rf build && rm -rf tmp",
    "compile": "run-p compile:*",
}

Can't we run the build command in lint-staged or is something missing in my implementation?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉薄对峙 2025-02-20 22:42:10

绒毛阶段将文件名传递到build脚本,而lerna认为这些是参数,无法解决它们。为了避免将文件名传递到构建脚本,请尝试将您的更改配置更改为以下内容

// lint-staged.config.js

module.exports = {
  '**/*.*': () => 'yarn build',
};

。上演 - 链接

lint-staged is passing filenames to the build script, whereas lerna thinks these are being arguments and can't resolve them. To avoid passing the filenames to the build script, try to change your lint-staged configuration to the following

// lint-staged.config.js

module.exports = {
  '**/*.*': () => 'yarn build',
};

Here is the link to a similar example in the lint-staged - Link

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文