在Google Cloud Platform上部署Vue Build

时间:2019-05-10 12:50:08

标签: google-app-engine google-cloud-platform bucket

我正在从“ vue”应用程序文件夹中运行命令“ gcloud app deploy”,最后出现vue-cli错误,并为其附加了快照。

enter image description here

2 个答案:

答案 0 :(得分:1)

似乎未安装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/\1
  upload: dist/(.*\..+)$  # catch all handler to index.html
- url: /.*
  static_files: dist/index.html
  upload: dist/index.html

注意:如果package.json不在存储库根目录中,则应在npm命令中将set定义为:

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

,如果app.yaml也不在根目录中,则用于在gcloud中进行部署:

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

答案 1 :(得分:0)

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

如果是这样,则可能是由于GAE与nodejs(npm)不兼容而引起的错误,如果要使用Vue,则需要在GAE flex中部署它。

另一个选择是,构建vue应用程序并在另一个运行时部署它,例如:python server;使用该构建作为静态站点。