Insied bitbucket管道错误:NodejsNpmBuilder:Resolver - 运行时的路径解析:二进制文件的nodejs20.x:npm不成功

问题描述 投票:0回答:1

我正在尝试使用 bitbucket pipeline 将我的无服务器节点代码与 SAM 部署到 AWS。

请注意,如果我在本地运行相同的命令,节点应用程序的构建、SAM 模板的构建和部署会完美运行。

这是我的 SAM 模板

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Betsy Core Lambda

Resources:
  BetsyCoreLambda:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: "betsy-core-dev"
      Handler: dist/serverless.handler
      Runtime: nodejs20.x
      CodeUri: ./
      MemorySize: 256
      Timeout: 20

这是我的 bitbucket-pipelines.yml

pipelines:
  branches:
    dev:
      - step:
          name: Build
          image: node:latest
          script:
            - npm install
            - npm run build
          artifacts:
            - dist/**
            - node_modules/**
            - package.json
      - step:
          name: Deploy to Dev
          oidc: true
          deployment: Development
          image: amazon/aws-cli
          script:
            - export AWS_WEB_IDENTITY_TOKEN_FILE=$(pwd)/web-identity-token
            - echo $BITBUCKET_STEP_OIDC_TOKEN > $(pwd)/web-identity-token

            - if [[ ! -f "sam-installation/dist/sam" ]]; then
                echo "SAM CLI not found. Installing...";
                yum install -y unzip;
                curl -Lo aws-sam-cli-linux-x86_64.zip https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip;
                unzip -q -o aws-sam-cli-linux-x86_64.zip -d sam-installation;
                ./sam-installation/install;
              fi
            - export PATH=$PATH:$(pwd)/sam-installation/dist/
            - sam --version

            - sam build -t template.yml
            - sam package --output-template-file packaged.yaml --s3-bucket $S3_CLOUDFORMATION_BUCKET
            - sam deploy --template-file packaged.yaml --stack-name betsy-core --capabilities CAPABILITY_IAM  --no-fail-on-empty-changeset --s3-bucket $S3_CLOUDFORMATION_BUCKET

这是我收到的错误:

+ sam build -t template.yml

    SAM CLI now collects telemetry to better understand customer needs.

    You can OPT OUT and disable telemetry collection by setting the

    environment variable SAM_CLI_TELEMETRY=0 in your shell.

    Thanks for your help!

    Learn More: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-telemetry.html

Building codeuri: /opt/atlassian/pipelines/agent/build runtime: nodejs20.x architecture: x86_64 functions: BetsyCoreLambda

Build Failed

Error: NodejsNpmBuilder:Resolver - Path resolution for runtime: nodejs20.x of binary: npm was not successful

如果这里有用的话是我的项目树

.
├── bitbucket-pipelines.yml
├── src/
├── nest-cli.json
├── package.json
├── package-lock.json
├── README.md
├── template.yml
├── tsconfig.build.json
└── tsconfig.json

请帮助我,我真的被困住了:(

node.js bitbucket-pipelines aws-sam
1个回答
0
投票

检查您在 yaml 文件中使用的

node:latest
是否实际上与您在
sam
模板中使用的相同。

我很确定不是,可能是22。 22 是标记为最新的 docker 映像,因此您实际上没有二进制文件。 只需在管道映像中指定节点 20 而不是最新节点即可。

© www.soinside.com 2019 - 2024. All rights reserved.