amazon-web-servicesaws-codebuild

AWS Codebuild: "No such file or directory"


I have an AWS Codebuild project that should build my eleventy project.

When the project runs npx @11ty/eleventy I can the following error:

/codebuild/output/src3281352166/src/node_modules/.bin/eleventy: line 1: ../@11ty/eleventy/cmd.js: No such file or directory

This is my buildspec.yml:

version: 0.2
    
phases:
  build:
    commands:
      - npm install
      - ls node_modules/@11ty/eleventy
      - npm run build

npm run build will just run npx @11ty/eleventy.

The ls command is just me trying to debug.

I can see from the debugging that node_modules/@11ty/eleventy/cmd.js is there.

Here is the output:

[Container] 2024/08/22 16:54:53.956093 CODEBUILD_SRC_DIR=/codebuild/output/src3281352166/src
[Container] 2024/08/22 16:54:53.959839 YAML location is /codebuild/output/src3281352166/src/buildspec.yml
...
[Container] 2024/08/22 16:54:54.380473 Entering phase BUILD
[Container] 2024/08/22 16:54:54.414109 Running command npm install
...
up to date, audited 218 packages in 6s
45 packages are looking for funding
  run `npm fund` for details
3 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
  npm audit fix --force
Run `npm audit` for details.

[Container] 2024/08/22 16:55:03.877896 Running command ls node_modules/@11ty/eleventy
CODE_OF_CONDUCT.md
LICENSE
README.md
SECURITY.md
cmd.js
package.json
src

[Container] 2024/08/22 16:55:03.887904 Running command npm run build
> eleventy@1.0.0 build
> npx @11ty/eleventy
/codebuild/output/src3281352166/src/node_modules/.bin/eleventy: line 1: ../@11ty/eleventy/cmd.js: No such file or directory

I assume the issue is something to do with the config, but the buildspec.yml file is definitely in the root of my project.

Please could you let me know how I should be configuring this build so that is correctly finds the cmd.js file?


Solution

  • In the end I deleted the @11ty/eleventy package from the package.json file, and continued to use npx @11ty/eleventy, which solved the issue.