【问题标题】:yarn lint fails in turborepoturborepo 中的 yarn lint 失败
【发布时间】:2022-07-23 18:39:33
【问题描述】:

我使用 turborepo 创建了一个 repo, 并具有以下文件夹结构

API 目录包含loopback API。

如果我从项目级别运行yarn lint,则会引发此错误

api:lint: $ lb-eslint --report-unused-disable-directives .
api:lint: node:internal/modules/cjs/loader:488
api:lint:       throw e;
api:lint:       ^
api:lint: 
api:lint: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './bin/eslint' is not defined by "exports" in ....Project0/node_modules/eslint/package.json
api:lint:     at new NodeError (node:internal/errors:371:5)
api:lint:     at throwExportsNotFound (node:internal/modules/esm/resolve:440:9)
api:lint:     at packageExportsResolve (node:internal/modules/esm/resolve:692:3)
api:lint:     at resolveExports (node:internal/modules/cjs/loader:482:36)
api:lint:     at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
api:lint:     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
api:lint:     at Function.resolve (node:internal/modules/cjs/helpers:108:19)
api:lint:     at resolveCLI (....Project0/node_modules/@loopback/build/bin/utils.js:76:18)
api:lint:     at Object.runCLI (....Project0/node_modules/@loopback/build/bin/utils.js:128:9)
api:lint:     at run (..../node_modules/@loopback/build/bin/run-eslint.js:45:16) {
api:lint:   code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
api:lint: }

如果我从 API 目录中运行相同的命令,也会出现同样的问题。 救命!

【问题讨论】:

  • 我们需要更多信息,您的根package.json 是什么样的?你的packages/是什么?

标签: node.js eslint turborepo


【解决方案1】:

按照文档,我能够在最新版本的 tubrorepo 和 loopback 4 中使用 linting。我建议使用git clean -fdx 删除目录中的所有孤立文件,而不是使用yarn install

➜  test-repo git:(main) ✗ yarn lint
yarn run v1.22.19
$ turbo run lint
• Packages in scope: apis, docs, eslint-config-custom, tsconfig, ui, web
• Running lint in 6 packages
apis:lint: cache miss, executing 088ca76a1deb7d80
ui:lint: cache miss, executing 01f15b1f691f55cb
docs:lint: cache miss, executing 2f27d4a1a57d2944
web:lint: cache miss, executing 252eb2868bb904ab
apis:lint: warning package.json: License should be a valid SPDX license expression
ui:lint: $ eslint *.ts*
docs:lint: $ next lint
web:lint: $ next lint
apis:lint: $ yarn run eslint && yarn run prettier:check
apis:lint: warning package.json: License should be a valid SPDX license expression
apis:lint: $ lb-eslint --report-unused-disable-directives .
docs:lint: ✔ No ESLint warnings or errors
apis:lint: warning package.json: License should be a valid SPDX license expression
web:lint: ✔ No ESLint warnings or errors
apis:lint: $ yarn run prettier:cli -l
apis:lint: warning package.json: License should be a valid SPDX license expression
apis:lint: $ lb-prettier "**/*.ts" "**/*.js" -l

 Tasks:    4 successful, 4 total
Cached:    0 cached, 4 total
  Time:    3.644s

【讨论】:

    猜你喜欢
    • 2018-06-20
    • 1970-01-01
    • 2019-11-11
    • 1970-01-01
    • 2019-10-02
    • 2019-04-13
    • 2018-05-12
    • 2021-11-18
    • 2015-11-06
    相关资源
    最近更新 更多