AWS Codebuild buildspec.yaml找不到文件

问题描述

]我为以打字稿编写的lambda函数服务设置了aws管道。我正在使用sam进行无服务器部署。在我的buildspec.yaml中,我有一条命令可以在package.json中运行我的一个预先构建的脚本来编译打字稿,但是代码构建表明没有这样的文件或目录。

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

]

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)