You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google App Engine突然无法部署Node.js应用求助

GAE部署时云端自动触发构建导致失败的解决办法

我有个简易Node.js/TypeScript项目,之前一直本地执行npm run build完成构建,再用gcloud app deploy --version=x部署到Google App Engine Node.js标准环境。今天部署时突然报错,云端居然自动执行了构建操作——但我已经把构建依赖的src目录加入.gcloudignore,只上传编译后的JS文件,之前从来没出现过这种情况。

报错信息如下:

Do you want to continue (Y/n)?  y

Beginning deployment of service [default]...
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 0 files to Google Cloud Storage                ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
Updating service [default]...failed.                                                                                                                                                                                                                                                                                    
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build 2e4915bf-4af5-4ede-80c8-196d55653451 status: FAILURE
> frontend@0.1.0 build
> webpack

assets by status 0 bytes [cached] 1 asset

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value.
Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/

ERROR in main
Module not found: Error: Can't resolve './src' in '/workspace'
resolve './src' in '/workspace'
using description file: /workspace/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
using description file: /workspace/package.json (relative path: ./src)
  no extension
    Field 'browser' doesn't contain a valid alias configuration
    /workspace/src is not a file
  .js
    Field 'browser' doesn't contain a valid alias configuration
    /workspace/src.js doesn't exist
  .json
    Field 'browser' doesn't contain a valid alias configuration
    /workspace/src.json doesn't exist
  .wasm
    Field 'browser' doesn't contain a valid alias configuration
    /workspace/src.wasm doesn't exist
  as directory
    existing directory /workspace/src
      using description file: /workspace/package.json (relative path: ./src)
        using path: /workspace/src/index
          using description file: /workspace/package.json (relative path: ./src/index)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /workspace/src/index doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /workspace/src/index.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /workspace/src/index.json doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /workspace/src/index.wasm doesn't exist

webpack 5.75.0 compiled with 1 error and 1 warning in 197 ms
Full build logs: https://console.cloud.google.com/cloud-build/builds;region=us-central1/2e4915bf-4af5-4ede-80c8-196d55653451?project=xxxxx

我的环境版本:
Google Cloud SDK:

Google Cloud SDK 413.0.0
alpha 2023.01.06
beta 2023.01.06
bq 2.0.84
bundled-python3-unix 3.9.12
cloud-datastore-emulator 2.3.0
core 2023.01.06
gcloud-crc32c 1.0.0
gsutil 5.17

Node.js版本:

leejjon@mymachine:~/projects/Blindpool$ node --version
v18.14.1

解决方法

  • 直接跳过云端构建:部署时添加--no-build参数,强制GAE只上传本地文件,不执行云端构建:
    gcloud app deploy --version=x --no-build
    
  • 修改app.yaml禁用构建:在app.yaml里明确指定跳过构建命令,避免GAE自动触发:
    runtime: nodejs18
    skip_files:
      - ^src/
      - ^node_modules/
    runtime_config:
      build_command: ""
    
  • 检查.gcloudignore配置:确认编译后的产物目录(比如dist)没被忽略,同时src、node_modules等构建依赖已正确加入忽略列表:
    src/
    node_modules/
    .git/
    
  • 排查SDK更新影响:你的gcloud SDK版本是2023年1月的,可能是SDK更新改变了默认部署行为,试试上面的参数或配置就能解决。

内容的提问来源于stack exchange,提问作者Leejjon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 00:43:21