【问题标题】:Deploy Vue Build On Google Cloud Platform在 Google Cloud Platform 上部署 Vue Build
【发布时间】:2019-05-10 12:50:08
【问题描述】:

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

【问题讨论】:

  • 欢迎来到 SO!请不要将文本作为图像发布,而是将其复制粘贴到您的帖子中并相应地格式化。谢谢。
  • 请让您的问题有价值,以便每个人都能从问题和答案中受益。 stackoverflow.com/help/how-to-ask 截图链接断开或被删除,使您的问题在未来变得毫无价值或令人困惑。

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


【解决方案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"]

【讨论】:

    【解决方案2】:

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

    如果是,可能是GAE不兼容nodejs(npm)导致报错,如果你想使用这种方式的Vue,你需要将它部署在GAE flex中。

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

    【讨论】:

    • 是的,我正在 GAE 上部署应用程序。我会用 GAE flex 试试。
    • 下面是我的 app.yaml 文件,运行时:nodejs env: flex api_version: 1 threadsafe: true handlers: - url: /(.*\.(js|css|png|jpg|svg| ttf|ico|manifest))$ static_files: dist/\1 上传: dist/.*\.(js|css|png|jpg|svg|ttf)$ - url: /.* static_files: dist/index.html 上传: dist/index.html
    • 我没有发现您的 app.yaml 有任何问题,如果您可以尝试使用 GAE flex,请告诉我是否解决了问题
    猜你喜欢
    • 2020-11-14
    • 1970-01-01
    • 2018-06-09
    • 1970-01-01
    • 2020-09-26
    • 2016-04-02
    • 1970-01-01
    • 2023-03-12
    • 2018-12-24
    相关资源
    最近更新 更多