skip to Main Content

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
> [email protected] 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?

2

Answers


  1. can you please modify and try this, just trying to brute fore and run it 😀 :

    version: 0.2
    
    phases:
      install:
        commands:
          - npm install
    
      build:
        commands:
          - ls node_modules/@11ty/eleventy
          - ln -sf ../@11ty/eleventy/cmd.js node_modules/.bin/eleventy
          - npm run build
    
    Login or Signup to reply.
  2. Instead of relying on npx to resolve the symlink, you can directly invoke the cmd.js script using Node.js.

    Update your build script in package.json to:

    "scripts": {
      "build": "node ./node_modules/@11ty/eleventy/cmd.js"
    }
    

    If you want to continue using npx, you can specify the full path to cmd.js in your build script:

    "scripts": {
      "build": "npx node ./node_modules/@11ty/eleventy/cmd.js"
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search