在 Google 云平台上部署 Vue 构建

Deploy Vue Build On Google Cloud Platform

我正在从我的 "vue" 应用程序文件夹中 运行 命令 "gcloud app deploy",最后收到 vue-cli 错误,附上快照。

您是否正在尝试在 GAE (Google App Engine) 上部署应用程序?

如果是的话,可能是因为GAE不兼容nodejs(npm)导致的,如果要使用Vue那样的方式,需要在GAE flex中部署。

另一种选择是,构建 vue 应用程序并使用另一个运行时部署它,例如:python 服务器;将构建用作静态站点。

似乎没有安装 vue-cli-service 这是我的 cloudbuild.yaml 如果有帮助 步骤:

- name: node
  entrypoint: npm
  args: ['install']
# Necessary for vue.js projects
- name: node
  entrypoint: npm
  args: ['install', '-g', '@vue/cli']
- name: node
  entrypoint: npm
  args: ['test']
- name: node
  entrypoint: npm
  args: ['run', 'build']
- name: "gcr.io/cloud-builders/gcloud"
  args: ["app", "deploy"]

app.yaml:

runtime: nodejs12
handlers:
  # Serve all static files with urls ending with a file extension
- url: /(.*\..+)$ 
  static_files: dist/
  upload: dist/(.*\..+)$  # catch all handler to index.html
- url: /.*
  static_files: dist/index.html
  upload: dist/index.html

注意:如果您的 package.json 不在您的存储库根目录中,您应该在 npm 命令中将设置定义为:

    - name: node
      entrypoint: npm
   # --prefix and path:
      args: ['install','--prefix','myapp']

如果 app.yaml 也不在 root 中,则在 gcloud 中部署:

- name: "gcr.io/cloud-builders/gcloud"
  args: ["app", "deploy","myapp/app.yaml"]