Posted By: Anonymous
I was trying to automate the deployment process of my Next.JS application to App Engine using Cloud Build but at the
build phase it keeps on failing with:
Error: > Build directory is not writeable. https://err.sh/vercel/next.js/build-dir-not-writeable
I cant seem to figure out what to fix for this.
My current build file is and it keeps failing on step 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"
runtime: nodejs12 handlers: - url: /.* secure: always script: auto env_variables: PORT: 8080 NODE_ENV: 'production'
any help would be appreciated
Can reproduce the same behavior after upgrading to next version 9.3.3.
The issue is related to the npm dependency which is managed by google if you use
gcr.io/cloud-builders/npm seems they are running your build inside of Google Cloud Build on an old node version.
Here you can find the currently supported version
As you can see Googles latest node version is 10.10. The newest next.js version requires at least node 10.13
- name: node entrypoint: npm
in order to use the official docker npm package which runs on node12.
After those changes your build will be successful again.
Switching to the official npm will increase the build duration (at least in my case). It takes around 2 minutes longer then the gcr npm.