gpt4 book ai didi

reactjs - 如何调试 react 脚本挂起?

转载 作者:行者123 更新时间:2023-12-03 14:00:15 25 4
gpt4 key购买 nike

我正在 AWS ECS 上使用 docker 部署 create-react-app。我正在使用 dockerhub 图像进行测试,该图像几乎是 create-react-app 的库存版本。启动任务时,它可以拉取容器镜像,启动 docker 容器,但是它会卡在运行react-scripts start上。我在容器日志中只能看到:

01:51:38 npm info it worked if it ends with ok
01:51:38 npm info using npm@2.15.11
01:51:38 npm info using node@v4.7.3
01:51:42 npm info prestart test-react@0.1.0
01:51:42 npm info start test-react@0.1.0
01:51:42 > test-react@0.1.0 start /usr/src/app
01:51:42 > react-scripts start
01:52:06 Starting the development server...

它只是卡在那里,永远不会结束。但是,当我手动运行 docker 容器时,一切正常:

Starting the development server...
Compiled successfully!

The app is running at:

http://localhost:3000/

我的 Dockerfile 是:

FROM node:4-onbuild

# Prepare app directory
RUN mkdir -p /usr/src/app
ADD . /usr/src/app

# Install dependencies
WORKDIR /usr/src/app
RUN npm install

# Build the app
RUN npm build

# Expose the app port
EXPOSE 3000

# Start the app
CMD npm start --loglevel debug

我的package.json:

    "scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}

寻求有关如何调试或是否可以进行其他日志记录的建议,谢谢!

最佳答案

我发现了 - 当我在 ECS 任务中创建定义容器时,我没有为 docker 容器分配足够的内存,因此当它启动服务器时,它会耗尽内存并卡住。我更改了设置以向 docker 容器分配更多内存,现在一切正常。

关于reactjs - 如何调试 react 脚本挂起?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42080622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com