web-dev-qa-db-ja.com

コマンドの実行中にコードビルドがエラーで失敗しました:NPM Install。理由:終了ステータス127

私は非常に単純なコードを持つコードパイプラインを作成し、CodeCommitに接続しました。それを構築しようとしましたが、CodeBuildステップで失敗していますが、NPMインストールの実行中のエラーがあります。申し訳ありませんが、このCodeBuild/Codepepelineに新しいものでした

以下はCodeBuild失敗のログです

[Container] 2019/02/15 11:47:39 Waiting for agent ping 
[Container] 2019/02/15 11:47:40 Waiting for DOWNLOAD_SOURCE 
[Container] 2019/02/15 11:47:40 Phase is DOWNLOAD_SOURCE 
[Container] 2019/02/15 11:47:40 CODEBUILD_SRC_DIR=/codebuild/output/src501317273/src 
[Container] 2019/02/15 11:47:40 YAML location is /codebuild/output/src501317273/src/buildspec.yml 
[Container] 2019/02/15 11:47:40 Processing environment variables 
[Container] 2019/02/15 11:47:40 Moving to directory /codebuild/output/src501317273/src 
[Container] 2019/02/15 11:47:40 Registering with agent 
[Container] 2019/02/15 11:47:40 Phases found in YAML: 1 
[Container] 2019/02/15 11:47:40 BUILD: 2 commands 
[Container] 2019/02/15 11:47:40 Phase complete: DOWNLOAD_SOURCE Success: true 
[Container] 2019/02/15 11:47:40 Phase context status code: Message: 
[Container] 2019/02/15 11:47:40 Entering phase INSTALL 
[Container] 2019/02/15 11:47:40 Phase complete: INSTALL Success: true 
[Container] 2019/02/15 11:47:40 Phase context status code: Message: 
[Container] 2019/02/15 11:47:40 Entering phase PRE_BUILD 
[Container] 2019/02/15 11:47:40 Phase complete: PRE_BUILD Success: true 
[Container] 2019/02/15 11:47:40 Phase context status code: Message: 
[Container] 2019/02/15 11:47:41 Entering phase BUILD 
[Container] 2019/02/15 11:47:41 Running command npm install 
sh: 1: npm: not found 

[Container] 2019/02/15 11:47:41 Command did not exit successfully npm install exit status 127 
[Container] 2019/02/15 11:47:41 Phase complete: BUILD Success: false 
[Container] 2019/02/15 11:47:41 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm install. Reason: exit status 127 
[Container] 2019/02/15 11:47:41 Entering phase POST_BUILD 
[Container] 2019/02/15 11:47:41 Phase complete: POST_BUILD Success: true 
[Container] 2019/02/15 11:47:41 Phase context status code: Message: 
[Container] 2019/02/15 11:47:41 Expanding base directory path: . 
[Container] 2019/02/15 11:47:41 Assembling file list 
[Container] 2019/02/15 11:47:41 Expanding . 
[Container] 2019/02/15 11:47:41 Expanding artifact file paths for base directory . 
[Container] 2019/02/15 11:47:41 Assembling file list 
[Container] 2019/02/15 11:47:41 Expanding post-saml.yaml 
[Container] 2019/02/15 11:47:41 Skipping invalid artifact path post-saml.yaml 
[Container] 2019/02/15 11:47:41 Expanding beta.json 
[Container] 2019/02/15 11:47:41 Found 1 file(s) 
[Container] 2019/02/15 11:47:41 Phase complete: UPLOAD_ARTIFACTS Success: true 
[Container] 2019/02/15 11:47:41 Phase context status code: Message: 
 _

my BuildSpec.ymlファイルはこのようになります

version: 0.0
environment_variables:
    plaintext:
        "INPUT_FILE": "serverless.yml"
        "S3_BUCKET": ""
containers:
    LambdaFunctions:
        phases:
            during_build:
                commands:
                    - npm install
                    - aws cloudformation package --template $INPUT_FILE --s3-bucket $S3_BUCKET --output-template post-saml.yaml
        artifacts:
            files:
                - post-saml.yaml
                - beta.json
 _

助けてくれてありがとう

6
Kishan

将来他の誰かがそれを渡って来る場合にここにこれを投稿するだけです。 op buildspec.yamlは、次のように更新された場合は働く必要があります BuildSpecリファレンス

チェンジログ:

  • buildSpecをバージョン.2に更新しました
  • インストールフェーズにノードjs依存関係を追加しました
version: 0.2
env:
  variables:
    INPUT_FILE: "serverless.yml"
    S3_BUCKET: ""
phases:
  install:
    runtime-versions:
      nodejs: 10
    commands:
      - npm install
  build:
    commands:
      - aws cloudformation package --template $INPUT_FILE --s3-bucket $S3_BUCKET --output-template post-saml.yaml
artifacts:
    files:
        - post-saml.yaml
        - beta.json
 _
0
Kevin