首页 > 解决方案 > 创建自定义无服务器模板时,“ServerlessError: serverless.yml not found”错误

问题描述

我试图创建一个自定义无服务器模板。

它是在我所做的所有无服务器项目之间共享相同的文件结构。

$ serverless create --template-url https://git-repository-url --path myService

以下是serverless模板的 git 存储库结构。

在此处输入图像描述

但是,当我运行上面的命令时,它会返回错误。

Serverless: Downloading and installing "xxxxxxxxxxx"...

  Serverless Error ---------------------------------------

  serverless.yml not found in /......../myService

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           10.6.0
     Serverless Version:     1.32.0

我做错了什么?

severless.yml如果我克隆存储库,我可以在根目录中看到一个文件。

标签: serverless-framework

解决方案


我应该使用 git 源路径 URL 而不仅仅是 git 存储库 URL。

# For github
https://github.com/user/repository-name/tree/branch-name/dir-path

# For bitbucket
https://bitbucket.com/user/repository-name/src/branch-name/dir-path

推荐阅读