首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用无服务器框架部署NodeJS函数时出现的问题

使用无服务器框架部署NodeJS函数时出现的问题
EN

Stack Overflow用户
提问于 2018-12-25 10:21:27
回答 2查看 279关注 0票数 0

我有一个具有此体系结构的应用程序:

代码语言:javascript
复制
-Function1
  .index.js
-Function2
  .index.py
  .requirements.txt
-Function3
  .index.py
  .requirements.txt
-Function4
  .index.py
  .requirements.txt
-node_modules
.serverless.yml
.package.json

我的问题是,当我调用无服务器部署时,我在NodeJS函数(Function1)中得到了更完整的应用程序。

这个问题只发生在NodeJS函数中,Python只有与每个函数相关的代码。

注意::我的serverless.yml中有这样的内容:

代码语言:javascript
复制
package:
  individually: true
plugins:
  - serverless-python-requirements
  - serverless-iam-roles-per-function
  - serverless-pseudo-parameters
  - serverless-plugin-include-dependencies

谢谢你的帮助。

EN

回答 2

Stack Overflow用户

发布于 2018-12-25 11:20:09

我使用/typescript/es7作为无服务器功能,请在serverless.yml中尝试:

代码语言:javascript
复制
plugins:
- ...
  - ...

provider:


name: aws
  runtime: **nodejs8.10**
  stage: ...
  profile: ...
  region: ...

functions:
  [function name]:
    handler: function1/index.js
    events:
      - http:
          method: get
          ...
票数 0
EN

Stack Overflow用户

发布于 2018-12-26 11:22:39

解决方案是在serverless.yml中使用排除/包含命令

所以我补充说:

代码语言:javascript
复制
package:
  exclude:
    - ./**
  include:
    - CreateThumbnail/index.handler
    - node_modules/**

现在,NodeJS函数只包含函数的节点、模块、依赖项和源代码。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53921419

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档