我是ReactJS世界的新手,帮助一个团队将他们的React应用程序部署到Docker容器。我做了以下任务。
/usr/src/app/src/index。js:1从“React”导入React^^^^^
_compile(内部/模块/cjs/loader.js:723: 23)在对象。_extensions... js(内部/模块/cjs/loader.js:789: 10)在Module.load(内部/模块/cjs/loader.js:653: 32)在tryModuleLoad(内部/模块/cjs/loader.js:593: 12)在函数。模块。_load(内部/模块/cjs/loader.js:585: 3)在函数。Module.run主(内部/模块/cjs/loader.js:831: 12)在启动(内部/引导/node.js:283: 19)在bootstrapNodeJSCore(内部/引导/node.js:623: 3)
我研究了这个错误,看起来这是因为编译、缺少网页包或React应用程序中的某些东西。我不知道该在哪里解决什么问题。
这里是package.json
文件,以防您可以帮助解决问题。
{
"name": "xxxx",
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.30",
"@fortawesome/free-solid-svg-icons": "^5.14.0",
"@fortawesome/react-fontawesome": "^0.1.11",
"@rjsf/core": "^2.3.0",
"@sentry/browser": "^5.23.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"FormData": "^0.10.1",
"append-query": "^2.1.0",
"axios": "^0.19.2",
"babel-loader": "8.1.0",
"bootstrap": "^4.5.2",
"es6-promise": "^4.2.8",
"install": "^0.13.0",
"lodash": "^4.17.20",
"log": "^6.0.0",
"mdbreact": "^4.27.0",
"node-sass": "^4.14.1",
"npm": "^6.14.8",
"react": "^16.13.1",
"react-bootstrap": "^1.3.0",
"react-bootstrap-tabs": "^2.0.0",
"react-confirm-alert": "^2.6.2",
"react-data-table-component": "^6.11.0",
"react-dom": "^16.13.1",
"react-fontawesome": "^1.7.1",
"react-jsonschema-form": "^1.8.1",
"react-popup": "^0.10.0",
"react-redux": "^7.2.0",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3",
"react-stepzilla": "^6.0.2",
"react-stepzilla-redux": "0.0.3",
"react-toastify": "^6.0.8",
"react-tooltip": "^4.2.8",
"reactstrap": "^8.5.1",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"styled-components": "5.1.0",
"validate": "^5.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/preset-env": "^7.11.5"
}
}
这里是DockerFile
的内容
FROM node:10
# FROM alpine:latest
WORKDIR /usr/src/app
# add node_modules/.bin:$path
ENV PATH /usr/src/app/node_modules/.bin:$PATH
# Install app dependencies
COPY package*.json ./
RUN npm install
# Bundle app source
COPY . .
#
EXPOSE 80
CMD npm start
而且,docker compose
文件如下所示。
version: "3"
services:
web:
build: ./pdf_web_frontend
command: "node src/index.js"
ports:
- "800:80"
你觉得上面有什么问题吗?蒂亚。
注意:我已经看到了这个链接同步错误:意外的标识符导入反应(Javascript)
经过大量研究,我可以部署这个react应用程序。以下是问题。
>
问题在于dockerfile
和dockercompose
文件。我添加了具有不同内容的全新文件。
React应用程序正在部署到某个糟糕的端口。因此,我在包中显式地添加了8080端口。json文件。这不是一个干净的解决方案,但它起了作用。
下面是新文件。
package.json
{
"name": "xxxx",
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.30",
"@fortawesome/free-solid-svg-icons": "^5.14.0",
"@fortawesome/react-fontawesome": "^0.1.11",
"@rjsf/core": "^2.3.0",
"@sentry/browser": "^5.23.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"FormData": "^0.10.1",
"append-query": "^2.1.0",
"axios": "^0.19.2",
"babel-loader": "8.1.0",
"bootstrap": "^4.5.2",
"es6-promise": "^4.2.8",
"install": "^0.13.0",
"lodash": "^4.17.20",
"log": "^6.0.0",
"mdbreact": "^4.27.0",
"node-sass": "^4.14.1",
"npm": "^6.14.8",
"react": "^16.13.1",
"react-bootstrap": "^1.3.0",
"react-bootstrap-tabs": "^2.0.0",
"react-confirm-alert": "^2.6.2",
"react-data-table-component": "^6.11.0",
"react-dom": "^16.13.1",
"react-fontawesome": "^1.7.1",
"react-jsonschema-form": "^1.8.1",
"react-popup": "^0.10.0",
"react-redux": "^7.2.0",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3",
"react-stepzilla": "^6.0.2",
"react-stepzilla-redux": "0.0.3",
"react-toastify": "^6.0.8",
"react-tooltip": "^4.2.8",
"reactstrap": "^8.5.1",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"styled-components": "5.1.0",
"validate": "^5.1.0"
},
"scripts": {
"start": "PORT=8080 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/preset-env": "^7.11.5"
}
}
Dockerfile
FROM node:alpine
WORKDIR /app
COPY package.json /app
RUN yarn install
COPY . /app
CMD ["yarn", "run", "start"]
docker撰写。yml
version: "3"
services:
client:
stdin_open: true
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
我在服务器上运行应用程序时出错,它在本地正常工作,我只需输入Run(npm start)并在本地正常运行。但和我在服务器上做的一样,我得到了下面给出的错误。请有人帮帮我。 {“name”:“chakde11”,“version”:“1.0.0”,“private”:false,“homepage”:http://chakde11.com/“,”依赖项“{bootstrap:“4.1.1”,“cha
我有一个简单的应用程序构建为docker图像(ubuntu),并把它放入docker容器。它有几个卷附加到它。我想将此容器推送到Azure AppServiceLinux。我尝试了几个选择,但没有成功。 > Azure CLI创建web应用程序并将容器推送到Azure容器注册表,然后将其部署到web应用程序。 给出错误。 将容器上传到,并更新Web应用容器设置以将此容器加载到Web应用中。 给出或
我正在尝试将.war、.aar、.xml和.properties文件部署到tomcat docker容器。我使用了下面的Dockerfile和基本的tomcat docker映像。 到目前为止一切正常。它提取war文件并启动容器内的应用程序。 但是现在我需要像这样添加/编辑“/usr/local/tomcat/webapps/root/web-inf//”和“/usr/local/tomcat/w
问题内容: 阅读MDN生成器的文档后,我想到了一个简单的实验: 在设置了标志的node.js v0.11.9上运行它会产生以下错误: 我也尝试使用and 关键字代替,但是没有成功。 我不明白到底是什么,但是如果我在循环中使用它,我会得到: 如果我用输出替换for中的收益,则和。我究竟做错了什么? 编辑 这是一个简约的生成器,显示node.js知道如何处理生成器: 输出: 解决方案(感谢@Andre
当我在glassfish 4.1中部署war文件时,会出现以下异常
所以我有安装了Qt addin的Visual Studio 2013(社区版),Qt5库(32位),我试图创建一个独立于所有开发配置的可执行文件(它可能使用静态或共享库,我现在真的不在乎)。 操作系统:Windows7,x64。 为此,我将visual studio选项从更改为,并在