- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 CI/CD 无服务器部署失败,因为它无法安装私有(private) npm 包。
Error --------------------------------------------------
npm install failed with code 1 npm ERR! code ENOENT npm ERR! syscall spawn git npm ERR! path git npm ERR! errno ENOENT npm ERR! enoent Error while executing: npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/private-org/private-repo.git npm ERR! enoent npm ERR! enoent npm ERR! enoent spawn git ENOENT npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent
npm ERR! A complete log of this run can be found in: npm ERR! /github/home/.npm/_logs/2020-05-28T13_30_18_595Z-debug.log
at ChildProcess.child.on.exitCode (/github/workspace/node_modules/serverless-webpack/lib/utils.js:91:16)
at ChildProcess.emit (events.js:198:13)
at ChildProcess.EventEmitter.emit (domain.js:448:20)
at maybeClose (internal/child_process.js:982:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)From previous event: at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:505:22) at PluginManager.spawn (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:525:17) at ServerlessWebpack.BbPromise.bind.then.then.then (/github/workspace/node_modules/serverless-webpack/index.js:91:53) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5) at process.topLevelDomainCallback (domain.js:126:23)
Get Support -------------------------------------------- Docs: docs.serverless.com Bugs: github.com/serverless/serverless/issues Issues: forum.serverless.com Your Environment Information --------------------------- Operating System: linux Node Version: 10.20.1 Framework Version: 1.54.0 Plugin Version: 3.6.12 SDK Version: 2.3.1 Components Core Version: 1.1.2 Components CLI Version: 1.4.0
deploy:
name: deploy
needs: test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- uses: webfactory/ssh-agent@v0.2.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: npm install
run: npm install
- name: serverless deploy
uses: serverless/github-action@master
with:
args: deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SLS_DEBUG: true
通常我使用 webfactory/ssh-agent@v0.2.0 解决这个问题,所以第一个 npm 安装在这里工作正常,它设法使用提供的 SSH key 安装私有(private)包。
然而,在无服务器部署期间,我收到上述错误并且无法安装私有(private) npm 包。有没有一种方法可以为无服务器操作指定 SSH key ?
最佳答案
我遇到了和你一样的错误,我错误地找到了解决方案。在 circleCI 中,无服务器正在读取包含私有(private) npm 包授权 token 的 ~/.npmrc 文件,但它没有读取包含私有(private)公司包路径的本地项目 .npmrc 文件。
所以不小心将私有(private)路径复制到 ~/.npmrc 并且神奇地部署成功了。
之后,我更新我的 circleCI 步骤以获取 ~/.npmrc 中的两条信息
step_login_github_packages: &step_login_github_packages
name: Log in to Github Packages
command: |
echo "//npm.pkg.github.com/:_authToken=$GITHUB_PACKAGES_TOKEN" >> ~/.npmrc
echo "@my-company:registry=https://npm.pkg.github.com/my-company" >> ~/.npmrc
关于serverless-framework - 如何在 sls 部署期间安装私有(private) npm github 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62066641/
我是一名优秀的程序员,十分优秀!