Next.js - 错误构建目录在 Google Cloud Build 上不可写
Next.js - ERROR Build directory is not writeable on Google Cloud Build
我试图使用 Cloud Build 将我的 Next.JS 应用程序的部署过程自动化到 App Engine,但在 build
阶段它一直失败并显示:
Error: > Build directory is not writeable. https://err.sh/vercel/next.js/build-dir-not-writeable
我似乎不知道要解决什么问题。
我当前的构建文件是,它在第 2 步一直失败:
steps:
# install dependencies
- name: 'gcr.io/cloud-builders/npm'
args: ['install']
# build the container image
- name: 'gcr.io/cloud-builders/npm'
args: ['run', 'build']
# deploy to app engine
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]
env:
- 'PORT=8080'
- 'NODE_ENV=production'
timeout: "1600s"
app.yaml:
runtime: nodejs12
handlers:
- url: /.*
secure: always
script: auto
env_variables:
PORT: 8080
NODE_ENV: 'production'
任何帮助将不胜感激
升级到下一版本 9.3.3 后可以重现相同的行为。
原因
如果您使用 gcr.io/cloud-builders/npm
似乎它们是 运行 您在 Google Cloud Build 上构建,则该问题与由 google 管理的 npm 依赖关系有关旧节点版本。
在这里你可以找到当前支持的版本
https://console.cloud.google.com/gcr/images/cloud-builders/GLOBAL/npm?gcrImageListsize=30
如您所见,Google的最新节点版本是 10.10。最新的 next.js 版本至少需要节点 10.13
解决方案
将gcr.io/cloud-builders/npm
改为
- name: node
entrypoint: npm
为了使用在 node12 上运行的官方 docker npm 包。
在这些更改之后,您的构建将再次成功。
旁注
切换到官方 npm 将增加构建持续时间(至少在我的情况下)。它比 gcr npm 多花大约 2 分钟。
我试图使用 Cloud Build 将我的 Next.JS 应用程序的部署过程自动化到 App Engine,但在 build
阶段它一直失败并显示:
Error: > Build directory is not writeable. https://err.sh/vercel/next.js/build-dir-not-writeable
我似乎不知道要解决什么问题。
我当前的构建文件是,它在第 2 步一直失败:
steps:
# install dependencies
- name: 'gcr.io/cloud-builders/npm'
args: ['install']
# build the container image
- name: 'gcr.io/cloud-builders/npm'
args: ['run', 'build']
# deploy to app engine
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]
env:
- 'PORT=8080'
- 'NODE_ENV=production'
timeout: "1600s"
app.yaml:
runtime: nodejs12
handlers:
- url: /.*
secure: always
script: auto
env_variables:
PORT: 8080
NODE_ENV: 'production'
任何帮助将不胜感激
升级到下一版本 9.3.3 后可以重现相同的行为。
原因
如果您使用 gcr.io/cloud-builders/npm
似乎它们是 运行 您在 Google Cloud Build 上构建,则该问题与由 google 管理的 npm 依赖关系有关旧节点版本。
在这里你可以找到当前支持的版本 https://console.cloud.google.com/gcr/images/cloud-builders/GLOBAL/npm?gcrImageListsize=30
如您所见,Google的最新节点版本是 10.10。最新的 next.js 版本至少需要节点 10.13
解决方案
将gcr.io/cloud-builders/npm
改为
- name: node
entrypoint: npm
为了使用在 node12 上运行的官方 docker npm 包。 在这些更改之后,您的构建将再次成功。
旁注
切换到官方 npm 将增加构建持续时间(至少在我的情况下)。它比 gcr npm 多花大约 2 分钟。