簡體   English   中英

如何使用無服務器部署包含 package.json?

[英]How to include package.json using serverless deploy?

我正在使用 webpack 和無服務器部署到 aws lambda。 到目前為止,我已經能夠將其配置為將所有依賴項捆綁到一個 ts 文件中,但 aws 抱怨沒有 package.json。 所以,我也找到了一種上傳節點模塊文件夾的方法,它還引入了 package.json 但因為我在 windows 上,所以就像 aws 實例一樣。

How do I include package.json when I run the serverless package or deploy commands so that aws lambda can run the install?

include:
      - package.json

不工作。

If you're using the Serverless Webpack plugin, you should be able to get whatever native modules you need installed by using the packagerOptions config for the plugin and specifying the linux platform for x64 architecture along with the list of npm modules to package.

有關更多信息,請參閱插件文檔的自定義腳本部分。

For example, if your Lambda function depends on the sharp npm package, you'd add something like the following to your serverless.yml file:

custom:
  webpack:
    includeModules: true
    packagerOptions:
      scripts:
        - npm_config_platform=linux npm_config_arch=x64 yarn add sharp

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM