我目前正在尝试在铁路上部署一个简单的笔记应用程序,这是课程挑战的一部分。 问题是,当我尝试部署它时,我收到以下消息:
#13 ERROR: executor failed running [/bin/bash -ol pipefail -c npm run build]: exit code: 1
-----
> [stage-0 9/10] RUN --mount=type=cache,id=s/b5d79573-cbdb-4229-892e-e66e9714107f-node_modules/cache,target=/app/node_modules/.cache npm run build:
-----
executor failed running [/bin/bash -ol pipefail -c npm run build]: exit code: 1
Error: Docker build failed`
I don´t know if i have a step missing or what could be the problem.
Full deploy log looks like this:
`#11 9.230 npm WARN deprecated [email protected]: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
#11 14.98 npm WARN deprecated [email protected]: This SVGO version is no longer supported. Upgrade to v2.x.x.
#11 24.47
#11 24.47 added 1477 packages, and audited 1478 packages in 23s
#11 24.47
#11 24.47 225 packages are looking for funding
#11 24.47 run `npm fund` for details
#11 24.48
#11 24.48 6 high severity vulnerabilities
#11 24.48
#11 24.48 To address all issues (including breaking changes), run:
#11 24.48 npm audit fix --force
#11 24.48
#11 24.48 Run `npm audit` for details.
#11 DONE 24.8s
#12 [stage-0 8/10] COPY . /app/
#12 sha256:2d146d3acb5f7b6934547b67ce82a0f989ce063f5c00e1d16417c4615811a113
#12 DONE 0.1s
#13 [stage-0 9/10] RUN --mount=type=cache,id=s/b5d79573-cbdb-4229-892e-e66e9714107f-node_modules/cache,target=/app/node_modules/.cache npm run build
#13 sha256:0e2d30e554f378b0753874cd9b0b7a11b369b2136a5ff7e9aebc245d3e0350b1
#13 1.002 npm
WARN config production Use `--omit=dev` instead.
#13 1.020
#13 1.020 > [email protected] build
#13 1.020 > react-scripts build
#13 1.020
#13 3.128 Creating an optimized production build...
#13 13.27
#13 13.27 Treating warnings as errors because process.env.CI = true.
#13 13.27 Most CI servers set it automatically.
#13 13.27
#13 13.27 Failed to compile.
#13 13.27
#13 13.27 [eslint]
#13 13.27 src/App.js
#13 13.27 Line 2:8: 'axios' is defined but never used no-unused-vars
#13 13.27
#13 13.27 src/services/notes.js
#13 13.27 Line 20:1: Assign object to a variable before exporting as module default import/no-anonymous-default-export
#13 13.27
#13 13.27
#13 ERROR: executor failed running [/bin/bash -ol pipefail -c npm run build]: exit code: 1
-----
> [stage-0 9/10] RUN --mount=type=cache,id=s/b5d79573-cbdb-4229-892e-e66e9714107f-node_modules/cache,target=/app/node_modules/.cache npm run build:
-----
executor failed running [/bin/bash -ol pipefail -c npm run build]: exit code: 1
Error: Docker build failed`
我也尝试将它部署在 render.com 上,然后我想,也许我必须在我的 React 应用程序中运行 run build 才能让它工作?抱歉代码很长,这是我第一次部署,我真的很困惑这部分。
Nov 8 09:27:22 PM ==> Cloning from https://github.com/Conwa/fullstackopen-excersices...
Nov 8 09:27:23 PM ==> Checking out commit 3dab108962d01d95622cb999c14c573a14e042fb in branch main
Nov 8 09:27:25 PM ==> Downloading cache...
Nov 8 09:27:35 PM ==> Transferred 33MB in 8s. Extraction took 0s.
Nov 8 09:27:38 PM ==> Installing dependencies with npm...
Nov 8 09:28:09 PM
Nov 8 09:28:09 PM > [email protected] postinstall /opt/render/project/src/part2/notes/node_modules/core-js
Nov 8 09:28:09 PM > node -e "try{require('./postinstall')}catch(e){}"
Nov 8 09:28:09 PM
Nov 8 09:28:09 PM
Nov 8 09:28:09 PM > [email protected] postinstall /opt/render/project/src/part2/notes/node_modules/core-js-pure
Nov 8 09:28:09 PM > node -e "try{require('./postinstall')}catch(e){}"
Nov 8 09:28:09 PM
Nov 8 09:28:10 PM added 1476 packages from 699 contributors and audited 1477 packages in 31.896s
Nov 8 09:28:11 PM
Nov 8 09:28:11 PM 225 packages are looking for funding
Nov 8 09:28:11 PM run `npm fund` for details
Nov 8 09:28:11 PM
Nov 8 09:28:11 PM found 1 high severity vulnerability
Nov 8 09:28:11 PM run `npm audit fix` to fix them, or `npm audit` for details
Nov 8 09:28:20 PM audited 1477 packages in 8.269s
Nov 8 09:28:21 PM
Nov 8 09:28:21 PM 225 packages are looking for funding
Nov 8 09:28:21 PM run `npm fund` for details
Nov 8 09:28:21 PM
Nov 8 09:28:21 PM found 1 high severity vulnerability
Nov 8 09:28:21 PM run `npm audit fix` to fix them, or `npm audit` for details
Nov 8 09:28:30 PM ==> Using Python version: 3.7.10
Nov 8 09:28:34 PM ==> Empty build command; skipping build
Nov 8 09:28:46 PM ==> Uploading build...
Nov 8 09:28:46 PM ==> Build folder build does not exist!
Nov 8 09:28:46 PM ==> Build failed 😞
我刚刚遇到了完全相同的问题。原来是因为以下日志:“将警告视为错误,因为 process.env.CI = true。”
我认为这是因为 eslint 返回错误,例如“第 2:8 行:‘axios’已定义但从未使用 no-unused-vars”,因此它阻止构建正确编译。
要修复此问题,请在 Railway 设置下将构建命令更改为“CI=false npm run build”。这对我有用,尽管我对此很陌生并且不认为这是最佳实践。请感受更有经验的开发者的意见!
在我的 package.json 中,我将构建更改为如下所示:
"scripts": {
"develop": "concurrently \"react-scripts start\" \" nodemon ./src/services/server.js\"",
"start": "concurrently \"react-scripts start\" \" node ./src/services/server.js\"",
"build": "CI=false react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"seeds": "node ./src/services/seeds/index.js"
},
也遵循 Brian Mojica 的回答
您也可以删除package-lock.json文件
https://github.com/RafalWilinski/telegram-chatgpt-concierge-bot/issues/11