我的 bitbucket 中有 reactjs 项目。我正在尝试将其部署在我的 EC2 服务器中,但在部署阶段遇到错误。并且在检查错误时......它没有如图所示部署......我正在分享文件和错误......你们可以帮帮我吗?
构建规范.yml
# Do not change version. This is the version of aws buildspec, not the version of your buldspec file.
version: 0.2
phases:
pre_build:
commands:
#installs dependencies into the node_modules/ directory
- npm install
build:
commands:
- echo Build started on `date`
- echo Compiling
- npm run build
post_build:
commands:
- echo Build completed on `date`
# Include only the files required for your application to run.
artifacts:
files:
- public/**/*
- src/**/*
- package.json
- appspec.yml
- scripts/**/*
应用规范.yml
version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/server
permissions:
- object: /
pattern: "**"
owner: ec2-user
group: ec2-user
hooks:
BeforeInstall:
- location: scripts/before_install.sh
timeout: 300
runas: root
AfterInstall:
- location: scripts/after_install.sh
timeout: 300
runas: root
ApplicationStart:
- location: scripts/app_start.sh
timeout: 300
runas: root
before_install.sh
#!/bin/bash
cd /home/ec2-user/server
curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash -
yum -y install nodejs npm
after_install.sh
#!/bin/bash
cd /home/ec2-user/server
npm install
npm install --save react react-dom react-scripts react-particles-js
npm install pm2 -g
app_start.sh
#!/bin/bash
cd /home/ec2-user/server/src
npm start
pm2 start npm --name "econote-dashboard" -- start
pm2 startup
pm2 save
pm2 restart all
指定位置的错误 脚本:scripts/app_start.sh 未能在 300 秒内完成
Logs
[stdout] Line 41:12: Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
[stdout]
[stdout]useEffect(() => {
[stdout] async function fetchData() {
[stdout] // You can await here
[stdout] const response = await MyAPI.getData(someId);
[stdout] // ...
[stdout] }
[stdout] fetchData();
[stdout]}, [someId]); // Or [] if effect doesn't need props or state
[stdout]
[stdout]Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching react-hooks/exhaustive-deps
[stdout]
[stdout]src/components/Cards.js
[stdout] Line 4:9: 'imageClick' is assigned a value but never used no-unused-vars
[stdout] Line 7:3: Anchors must have content and the content must be accessible by a screen reader jsx-a11y/anchor-has-content
[stdout] Line 13:6: Using target="_blank" without rel="noreferrer" is a security risk: see https://html.spec.whatwg.org/multipage/links.html#link-type-noopener react/jsx-no-target-blank
[stdout]
[stdout]src/components/Dashboard.js
[stdout] Line 2:23: 'EpubView' is defined but never used no-unused-vars
[stdout]
[stdout]src/components/login.js
[stdout] Line 30:24: The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md jsx-a11y/anchor-is-valid
[stdout]
[stdout]Search for the keywords to learn more about each warning.
[stdout]To ignore, add // eslint-disable-next-line to the line before.
[stdout]
[stderr]Terminated