[英]Pipeline Serverless deploy fails on dependency install
我們正在使用 AWS Lambda,我正在嘗試自動化我們的部署。 serverless-offline 包在無服務器構建時生成錯誤。
這是一個多端點部署。 我們將部署多個目錄,因此管道中的cd console
。 我們可以使用無服務器部署手動部署就好了,但到目前為止我的自動化嘗試都失敗了。
我的管道.yml
image: lambci/lambda:build-nodejs6.10
pipelines:
default:
- step:
deployment: test
script:
- npm install
- npm install -g serverless
- npm install -g serverless-offline
- npm install -g serverless-domain-manager
- cd console # will be doing this for multiple directories, but just using one for now
- serverless plugin install --name serverless-webpack
- serverless plugin install --name serverless-offline
- serverless plugin install --name serverless-domain-manager
- serverless create -t aws-nodejs
- serverless deploy
我那個目錄的部分 serverless.yml
# Use the serverless-webpack plugin to transpile ES6
plugins:
- serverless-webpack
- serverless-offline
- serverless-domain-manager
# serverless-webpack configuration
# Enable auto-packing of external modules
custom:
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
customDomain:
我試過安裝使用
npm install -g serverless-offline
和
- serverless plugin install --name serverless-offline
。
如果我錯過了其中任何一個,我就會收到錯誤消息
Serverless plugin "serverless-offline" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file.
但現在我明白了
Serverless plugin "serverless-offline" initialization errored: Unexpected identifier
當我運行無服務器創建步驟時。
提前致謝。
發現問題,我需要全局安裝 serverless 但 npm install 在目錄內:
- npm install -g serverless
- git log --grep=console
- cd console
- npm install
您還可以在 package.json 文件中的 devDependencies 中添加無服務器版本:
"devDependencies": {
"serverless": "1.72.0",
....
}
然后在腳本部分添加自定義命令
"scripts": {
"sls:deploy": "serverless deploy",
.....
}
然后在你的pipeline.yml
- npm i
- npm run sls:deploy
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.