gpt4 book ai didi

node.js - 使用 craco 的 React App 不会在 docker-compose 中启动

转载 作者:行者123 更新时间:2023-12-05 04:36:39 34 4
gpt4 key购买 nike

我得到了一个 React 项目,我需要使用 Docker Compose 进行容器化。我有一个 Dockerfile:

FROM node:latest

# Create app directory
WORKDIR /usr/src/app

ENV PATH /app/node_modules/.bin:$PATH

COPY package.json ./

ADD . /usr/src/app

RUN npm install

EXPOSE 3000
CMD [ "npm", "start" ]

docker-compose.yml:

version: "3"

services:
front:
container_name: dev_front
environment:
- PATH= /app/node_modules/.bin:${PATH}
build:
context: .
ports:
- 3000:3000
restart: always

dev_front | craco: *** Cannot find ESLint loader (eslint-loader). ***
dev_front | The following changes are being made to your tsconfig.json file:
dev_front | - compilerOptions.paths must not be set (aliased imports are not supported)
dev_front |dev_front | ℹ 「wds」: Project is running at http://172.19.0.2/
dev_front | ℹ 「wds」: webpack output is served from
dev_front | ℹ 「wds」: Content not from webpack is served from /usr/src/app/public
dev_front | ℹ 「wds」: 404s will fallback to /

craco.config.js:

const CracoAlias = require("craco-alias");

module.exports = {
webpack: {
alias: {
'vscode': require.resolve('@codingame/monaco-languageclient/lib/vscode-compatibility')
},
devServer: {
host: '0.0.0.0',
port: 3000
}
},
plugins: [{
plugin: CracoAlias,
options: {
source: "tsconfig",
baseUrl: "./src",
tsConfigPath: "./tsconfig.extend.json"
}
}]
};

还是不行。

最佳答案

必须与 webpack 版本相关

解决方案是在 Dockerfile 中添加以下行:

ENV NODE_OPTIONS --openssl-legacy-provider

更多信息: Node.js 17.0.1 Gatsby error - "digital envelope routines::unsupported ... ERR_OSSL_EVP_UNSUPPORTED"

关于node.js - 使用 craco 的 React App 不会在 docker-compose 中启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70784550/

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