Next.js Vercel部署不运行codegen命令

ujv3wf0j  于 2023-11-18  发布在  其他
关注(0)|答案(1)|浏览(125)

我在pnpm上使用Typescript创建了一个React Next.js项目,并使用graphql-codegen/typescript创建类型。在vercel构建时,我得到了一个模块未找到的错误,用于导入使用codegen生成的类型。
在开发服务器上,我从终端手动使用'pnpm gen'命令生成类型。可能是下一次在vercel上构建时,它不运行此命令。我试图添加它,但找不到添加的位置。
这里是package.json

"scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "codegen": "graphql-codegen --require dotenv/config --config codegen.ts",
    "gen": "graphql-codegen --config codegen.ts"
  },
  "dependencies": {
    "@emotion/react": "^11.11.1",
    "@emotion/server": "^11.11.0",
    "@graphql-codegen/typescript": "^4.0.1",
    "@graphql-codegen/typescript-operations": "^4.0.1",
    "@graphql-typed-document-node/core": "^3.2.0",
    "@mantine/carousel": "^6.0.19",
    "@mantine/core": "^6.0.19",
    "@mantine/dates": "^6.0.19",
    "@mantine/form": "^6.0.19",
    "@mantine/hooks": "^6.0.19",
    "@mantine/next": "^6.0.19",
    "@react-icons/all-files": "^4.1.0",
    "@saleor/auth-sdk": "^0.8.0",
    "@tabler/icons": "^2.34.0",
    "@tabler/icons-react": "^2.31.0",
    "autoprefixer": "^10.4.15",
    "date-fns": "^2.30.0",
    "graphql": "^16.6.0",
    "graphql-tag": "^2.12.6",
    "next": "^13.4.3",
    "next-urql": "^5.0.1",
    "options": "^0.0.6",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-is": "^18.2.0",
    "tailwindcss": "^3.3.3",
    "ts-invariant": "^0.10.3",
    "urql": "^4.0.2"
  },
  "devDependencies": {
    "@graphql-codegen/cli": "5.0.0",
    "@graphql-codegen/client-preset": "4.1.0",
    "@types/node": "^20.2.3",
    "@types/react": "^18.2.6",
    "@types/react-dom": "^18.2.4",
    "dotenv": "^16.0.3",
    "eslint": "^8.41.0",
    "eslint-config-next": "^13.4.3",
    "ts-node": "^10.9.1",
    "typescript": "^5.0.4"
  }
}

字符串

igsr9ssn

igsr9ssn1#

Vercel Jmeter 板,点击你的项目,然后点击Settings标签。在General标签侧边栏,你会发现Build & Development Settings部分,然后项目设置折叠区域,覆盖构建命令为pnpm gen && pnpm build,然后点击保存。

相关问题