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
错误详情
- 首次错误:构建日志显示
package-lock.json缺失typescript@4.9.5、ajv@6.12.6等依赖包,执行npm install并推送至仓库后问题未解决。 - 后续操作:删除
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
相关产品推荐
相关产品推荐

