Keystone 在 Turborepo 内崩溃

Keystone crashes inside Turborepo

Keystone fails to find dependencies while running yarn build inside a new Turborepo 项目。

重现步骤

  1. 在新项目中安装 Turborepo npx create-turbo@latest

  2. 导航到应用程序文件夹或您计划安装 Keystone cd 应用程序的任何位置/

  3. 安装梯形校正yarn create keystone-app

  4. 导航回根目录cd ../

  5. 添加.keystone/** to turbo.json管道:

"build": {"dependsOn": [ "^build" ], "outputs": [ ".next/**", ".keystone/admin/.next/**" ]}}
  1. 从根目录构建项目cd ../ && yarn build

观察内部的错误信息./keystone

turbo.json

{
  "pipeline": {
    "build": {
      "dependsOn": [
        "^build"
      ],
      "outputs": [
        ".next/**",
        ".keystone/admin/.next/**"
      ]
    },
    "dev": {
      "cache": false
    },
    "clean": {
      "cache": false
    }
  },
  "globalDependencies": [
    "tsconfig.json",
    ".prettierrc.json",
    ".eslintrc.json",
    "Procfile"
  ]
}

package.json

{
  "private": true,
  "workspaces": [
    "packages/*",
    "apps/*"
  ],
  "scripts": {
    "build": "turbo run build",
    "dev": "turbo run dev --no-cache --parallel --continue",
    "lint": "turbo run lint",
    "test": "turbo run test",
    "clean": "turbo run clean && rm -rf node_modules",
    "format": "prettier --write \"**/*.{ts,tsx,js,md}\""
  },
  "devDependencies": {
    "prettier": "^2.5.1",
    "turbo": "latest"
  },
  "packageManager": "yarn@1.22.18"
}

apps/keystoneCMS/package.json

{
  "name": "logly-admin",
  "version": "1.0.0",
  "private": true,
  "main": "keystone.ts",
  "scripts": {
    "dev": "keystone dev",
    "start": "keystone start",
    "build": "keystone build && keystone prisma migrate deploy",
    "postinstall": "keystone postinstall"
  },
  "dependencies": {
    "@emotion/css": "^11.7.1",
    "@keystone-6/auth": "^1.0.1",
    "@keystone-6/cloudinary": "^1.0.0",
    "@keystone-6/core": "^1.1.0",
    "@keystone-6/fields-document": "^1.0.1",
    "@prisma/client": "^3.8.1",
    "autoprefixer": "^10.4.2",
    "dotenv": "^10.0.0",
    "formik": "^2.2.9",
    "postcss": "^8.4.7",
    "tailwind": "^4.0.0",
    "tailwindcss": "^3.0.23",
    "typescript": "^4.5.4"
  },
  "engines": {
    "node": "^14.15 || ^16.13"
  }
}

Github 发布更多上下文:https://github.com/keystonejs/keystone/issues/7518

版本 节点:v16.13.1(最新) Keystone:v6(最新) Turborepo:1.2.8(最新)

我已经能够复制这个,它看起来是 npx create-turbo@latest 安装并固定到的 next 版本的问题。 运行 create-turbo 安装 next 12.0.8 并固定到该版本。 Keystone 至少需要 12.1.0.

版本

当我将 ./apps/web/package.json 更改为:

  "dependencies": {
    "next": "^12.1.0",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "ui": "*"
  },

错误不再发生。