AWS Codebuild buildspec.yaml not finding files

Viewed 1985

]I have an aws pipeline set up for a lambda function service written in typescript. I am using sam for serverless deployment. In my buildspec.yaml I have a command that is suppose to run one of my pre built scripts in my package.json to compile typescript but the codebuild says there is no such file or directory.

phases:
  build:
    commands:
      - npm run compile
artifacts: 
  files:
    - package.json
    - package-lock.json
[Container] 2020/09/21 15:12:00 Waiting for agent ping
[Container] 2020/09/21 15:12:04 Waiting for DOWNLOAD_SOURCE
[Container] 2020/09/21 15:12:18 Phase is DOWNLOAD_SOURCE
[Container] 2020/09/21 15:12:18 CODEBUILD_SRC_DIR=/codebuild/output/src071783151/src
[Container] 2020/09/21 15:12:18 YAML location is /codebuild/output/src071783151/src/config/buildspec.dev.yml
[Container] 2020/09/21 15:12:18 Processing environment variables
[Container] 2020/09/21 15:12:18 No runtime version selected in buildspec.
[Container] 2020/09/21 15:12:18 Moving to directory /codebuild/output/src071783151/src
[Container] 2020/09/21 15:12:18 Registering with agent
[Container] 2020/09/21 15:12:18 Phases found in YAML: 1
[Container] 2020/09/21 15:12:18  BUILD: 1 commands
[Container] 2020/09/21 15:12:18 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED
[Container] 2020/09/21 15:12:18 Phase context status code:  Message: 
[Container] 2020/09/21 15:12:18 Entering phase INSTALL
[Container] 2020/09/21 15:12:18 Phase complete: INSTALL State: SUCCEEDED
[Container] 2020/09/21 15:12:18 Phase context status code:  Message: 
[Container] 2020/09/21 15:12:18 Entering phase PRE_BUILD
[Container] 2020/09/21 15:12:18 Phase complete: PRE_BUILD State: SUCCEEDED
[Container] 2020/09/21 15:12:18 Phase context status code:  Message: 
[Container] 2020/09/21 15:12:18 Entering phase BUILD
[Container] 2020/09/21 15:12:18 Running command npm run compile
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /codebuild/output/src071783151/src/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/codebuild/output/src071783151/src/package.json'
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!     /root/.npm/_logs/2020-09-21T15_12_25_587Z-debug.log

[Container] 2020/09/21 15:12:25 Command did not exit successfully npm run compile exit status 254
[Container] 2020/09/21 15:12:25 Phase complete: BUILD State: FAILED
[Container] 2020/09/21 15:12:25 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm run compile. Reason: exit status 254
[Container] 2020/09/21 15:12:25 Entering phase POST_BUILD
[Container] 2020/09/21 15:12:25 Phase complete: POST_BUILD State: SUCCEEDED
[Container] 2020/09/21 15:12:25 Phase context status code:  Message: 
[Container] 2020/09/21 15:12:25 Expanding base directory path: .
[Container] 2020/09/21 15:12:25 Assembling file list
[Container] 2020/09/21 15:12:25 Expanding .
[Container] 2020/09/21 15:12:25 Expanding file paths for base directory .
[Container] 2020/09/21 15:12:25 Assembling file list
[Container] 2020/09/21 15:12:25 Expanding package.json
[Container] 2020/09/21 15:12:25 Skipping invalid file path package.json
[Container] 2020/09/21 15:12:25 Expanding package-lock.json
[Container] 2020/09/21 15:12:25 Skipping invalid file path package-lock.json

[File Structure]

0 Answers
Related