我有一个使用 AWS CodePipeline 部署的 SvelteKit 应用程序。
我的管道在推送到 CodeCommit 时被触发。但 CodeBuild 失败并显示以下错误消息:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project-title@0.0.1 build: `svelte-kit build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project-title@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[Container] 2021/11/30 14:45:25 Command did not exit successfully npm run build exit status 1
我尝试克隆存储库并在我的 PC 上的干净环境中构建它,它构建时没有任何错误。我无法在 CodeBuild 之外重现该问题。
buildspec.yml
version: 0.2
phases:
install:
commands:
- echo "Entered the install phase..."
- npm install
pre_build:
commands:
- echo "Entered the pre_build phase..."
build:
commands:
- echo "Entered the build phase..."
- echo "Build started on `date`"
- npm run build
post_build:
commands:
- echo "Entered the post_build phase..."
- echo "Build completed on `date`"
artifacts:
files:
- '**/*'
name: project-title
包.json
{
"name": "project-title",
"version": "0.0.1",
"scripts": {
"dev": "svelte-kit dev",
"build": "svelte-kit build",
"preview": "svelte-kit preview",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
},
"devDependencies": {
"@sveltejs/adapter-static": "^1.0.0-next.21",
"@sveltejs/kit": "next",
"autoprefixer": "^10.4.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^3.2.1",
"prettier": "^2.4.1",
"prettier-plugin-svelte": "^2.4.0",
"svelte": "^3.42.6",
"tailwindcss": "^2.2.19"
},
"type": "module"
}
苗条的.config.js
import adapter from '@sveltejs/adapter-static';
export default {
kit: {
adapter: adapter({
// default options are shown
pages: 'build',
assets: 'build',
fallback: null
})
}
};
CodeBuild 项目环境: