You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS Amplify构建失败:package-lock.json与npm ci相关问题

AWS Amplify部署React应用构建失败问题排查

问题背景

按照AWS官方教程部署全栈React应用,构建阶段失败,出现文件/依赖缺失问题。严格遵循教程步骤操作,曾通过复制可用的package-lock.json文件解决过类似问题,但后续问题复现,需明确原因并找到可行的解决方法。

本地执行的命令

npx create-react-app amplifyapp
cd amplifyapp
git init
git remote add origin https://github.com/AsafO7/amplify-react-graphql.git
git branch -M main
git add .
git commit -m "initial commit"
git push -u origin main

错误详情

  1. 首次错误:构建日志显示package-lock.json缺失typescript@4.9.5、ajv@6.12.6等依赖包,执行npm install并推送至仓库后问题未解决。
  2. 后续操作:删除package-lock.json与node_modules文件夹,执行npm i后依赖缺失错误消失,但出现npm ci相关执行错误,日志如下:
## Checking for associated backend environment...
## No backend environment association found, continuing...
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle]
npm ERR! [-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling]
npm ERR! [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
npm ERR! [--strict-peer-deps] [--no-package-lock] [--foreground-scripts]
npm ERR! [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run]
npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
npm ERR! [-ws|--workspaces] [--include-workspace-root] [--install-links]
npm ERR!
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info
npm
2023-03-06T10:57:53.792Z [WARNING]: ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2023-03-06T10_57_50_838Z-debug-0.log
2023-03-06T10:57:53.798Z [ERROR]: !!! Build failed
2023-03-06T10:57:53.799Z [ERROR]: !!! Non-Zero Exit Code detected
2023-03-06T10:57:53.799Z [INFO]: # Starting environment caching...
2023-03-06T10:57:53.799Z [INFO]: # Environment caching completed
Terminating logging...

求助

请问有什么解决方法?


内容的提问来源于stack exchange,提问作者Asaf

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 02:57:43