我有一个 AWS Codebuild 项目,应该可以构建我的 110 项目。
当项目运行时
npx @11ty/eleventy
我可以出现以下错误:
/codebuild/output/src3281352166/src/node_modules/.bin/eleventy:第1行:../@11ty/eleventy/cmd.js:没有这样的文件或目录
这是我的
buildspec.yml
:
version: 0.2
phases:
build:
commands:
- npm install
- ls node_modules/@11ty/eleventy
- npm run build
npm run build
只会运行 npx @11ty/eleventy
。
ls
命令只是我试图调试。
从调试中可以看到node_modules/@11ty/eleventy/cmd.js在那里。
这是输出:
[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
我认为问题与配置有关,但
buildspec.yml
文件肯定位于我项目的根目录中。
请让我知道应该如何配置此版本,以便正确找到
cmd.js
文件?
您可以修改一下并尝试一下吗:
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
- node node_modules/@11ty/eleventy/cmd.js