我使用 Mac 笔记本电脑来运行我的项目,它可以工作,但我开始使用新的笔记本电脑,现在我的项目无法编译。
我目前在 macOS Big Sur v11.1 上使用 Docker Desktop v3.0.4
如果我在没有 Docker 的情况下运行我的 React 项目,它会编译并运行。所以我假设它是一个 docker 问题,但无法弄清楚它是什么。可能是版本问题。
docker-compose.yml:
version: "3.2"
services:
frontend:
build: ./frontend
volumes:
- ./frontend:/app
#One-way volume to use node_modules from inside image
- /app/node_modules
ports:
- "3000:3000"
#tty: true
command: npm start
Dockerfile:
# Use an official node runtime as a parent image
FROM node:8
ENV NPM_CONFIG_LOGLEVEL warn
#allows app_env to be set during build (defaults to empty string)
ARG app_env
#sets an environment variable to app_env argument, this way the variable will persist in the container for use in code
ENV APP_ENV $app_env
#all subsequent commands will now be run from inside this folder
WORKDIR /app/
#copy dependencies file
COPY package.json /app/
# Install dependencies
RUN npm install
# Add rest of the client code
COPY . /app/
EXPOSE 3000
CMD npm start
当我运行 docker-compose --verbose up --build
时,输出是
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.41/containers/35ad92f5ac5ac433cedc991461be3b2d58dec97176db32e656010a4529f1eb49/start HTTP/1.1" 204 0
compose.cli.verbose_proxy.proxy_callable: docker start -> None
Creating websites_frontend_1 ... done
compose.parallel.feed_queue: Pending: set()
compose.parallel.parallel_execute_iter: Finished processing: <Service: frontend>
compose.parallel.feed_queue: Pending: set()
Attaching to websites_frontend_1
compose.cli.verbose_proxy.proxy_callable: docker events <- (filters={'label': ['com.docker.compose.project=websites', 'com.docker.compose.oneoff=False']}, decode=True)
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.41/events?filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dwebsites%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker events -> <docker.types.daemon.CancellableStream object at 0x10a619f90>
frontend_1 |
frontend_1 | > internal-beta-frontend@0.1.0 start /app
frontend_1 | > react-scripts start
frontend_1 |
frontend_1 | ℹ 「wds」: Project is running at http://172.18.0.2/
frontend_1 | ℹ 「wds」: webpack output is served from
frontend_1 | ℹ 「wds」: Content not from webpack is served from /app/public
frontend_1 | ℹ 「wds」: 404s will fallback to /
frontend_1 | Starting the development server...
frontend_1 |
compose.cli.verbose_proxy.proxy_callable: docker wait <- ('35ad92f5ac5ac433cedc991461be3b2d58dec97176db32e656010a4529f1eb49')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('35ad92f5ac5ac433cedc991461be3b2d58dec97176db32e656010a4529f1eb49')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.41/containers/35ad92f5ac5ac433cedc991461be3b2d58dec97176db32e656010a4529f1eb49/json HTTP/1.1" 200 None
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.41/containers/35ad92f5ac5ac433cedc991461be3b2d58dec97176db32e656010a4529f1eb49/wait HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker wait -> {'Error': None, 'StatusCode': 0}
websites_frontend_1 exited with code 0
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': '',
'Args': ['npm', 'start'],
'Config': {'AttachStderr': False,
'AttachStdin': False,
'AttachStdout': False,
'Cmd': ['npm', 'start'],
'Domainname': '',
'Entrypoint': ['docker-entrypoint.sh'],
'Env': ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
'NODE_VERSION=8.17.0',
...
为什么我的项目没有建立?我需要做什么才能让它运行?
答案 0 :(得分:0)
我遇到了同样的问题,解决方法是将项目从 Spotlight
索引工具中排除。似乎这个使用了大量资源并且导致构建失败。转到 System preferences
,然后搜索 Spotlight
。然后转到 Privacy
选项卡并添加包含您的项目的目录。这可能会有所帮助。