铁路部署构建失败

Con*_*rlo 1 deployment build express reactjs

我目前正在尝试在铁路上部署一个简单的笔记应用程序,这是课程挑战的一部分。\n问题是,当我尝试部署它时,我收到以下消息:

\n
#13 ERROR: executor failed running [/bin/bash -ol pipefail -c npm run build]: exit code: 1\n \n-----\n> [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:\n-----\n \nexecutor failed running [/bin/bash -ol pipefail -c npm run build]: exit code: 1\n \nError: Docker build failed`\n\n\nI don\xc2\xb4t know if i have a step missing or what could be the problem.\n\nFull deploy log looks like this: \n\n \n`#11 9.230 npm WARN deprecated stable@0.1.8: 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\n \n#11 14.98 npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.\n \n#11 24.47\n#11 24.47 added 1477 packages, and audited 1478 packages in 23s\n#11 24.47\n#11 24.47 225 packages are looking for funding\n#11 24.47   run `npm fund` for details\n#11 24.48\n#11 24.48 6 high severity vulnerabilities\n#11 24.48\n#11 24.48 To address all issues (including breaking changes), run:\n#11 24.48   npm audit fix --force\n#11 24.48\n#11 24.48 Run `npm audit` for details.\n \n#11 DONE 24.8s\n \n#12 [stage-0  8/10] COPY . /app/\n#12 sha256:2d146d3acb5f7b6934547b67ce82a0f989ce063f5c00e1d16417c4615811a113\n#12 DONE 0.1s\n \n \n#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\n#13 sha256:0e2d30e554f378b0753874cd9b0b7a11b369b2136a5ff7e9aebc245d3e0350b1\n \n#13 1.002 npm\nWARN config production Use `--omit=dev` instead.\n#13 1.020\n#13 1.020 > notes@0.1.0 build\n#13 1.020 > react-scripts build\n#13 1.020\n \n#13 3.128 Creating an optimized production build...\n \n#13 13.27\n#13 13.27 Treating warnings as errors because process.env.CI = true.\n#13 13.27 Most CI servers set it automatically.\n#13 13.27\n#13 13.27 Failed to compile.\n#13 13.27\n#13 13.27 [eslint]\n#13 13.27 src/App.js\n#13 13.27   Line 2:8:  'axios' is defined but never used  no-unused-vars\n#13 13.27\n#13 13.27 src/services/notes.js\n#13 13.27   Line 20:1:  Assign object to a variable before exporting as module default  import/no-anonymous-default-export\n#13 13.27\n#13 13.27\n \n#13 ERROR: executor failed running [/bin/bash -ol pipefail -c npm run build]: exit code: 1\n \n-----\n> [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:\n-----\n \nexecutor failed running [/bin/bash -ol pipefail -c npm run build]: exit code: 1\n \nError: Docker build failed`\n
Run Code Online (Sandbox Code Playgroud)\n

我尝试将它部署在 render.com 上,然后我想,也许我必须在我的 React 应用程序中运行 run build 才能让它工作?抱歉代码很长,这是我第一次部署,而 i\xc2\xb4m 确实卡在了这部分。

\n
Nov 8 09:27:22 PM  ==> Cloning from https://github.com/Conwa/fullstackopen-excersices...\nNov 8 09:27:23 PM  ==> Checking out commit 3dab108962d01d95622cb999c14c573a14e042fb in branch main\nNov 8 09:27:25 PM  ==> Downloading cache...\nNov 8 09:27:35 PM  ==> Transferred 33MB in 8s. Extraction took 0s.\nNov 8 09:27:38 PM  ==> Installing dependencies with npm...\nNov 8 09:28:09 PM  \nNov 8 09:28:09 PM  > core-js@3.26.0 postinstall /opt/render/project/src/part2/notes/node_modules/core-js\nNov 8 09:28:09 PM  > node -e "try{require('./postinstall')}catch(e){}"\nNov 8 09:28:09 PM  \nNov 8 09:28:09 PM  \nNov 8 09:28:09 PM  > core-js-pure@3.26.0 postinstall /opt/render/project/src/part2/notes/node_modules/core-js-pure\nNov 8 09:28:09 PM  > node -e "try{require('./postinstall')}catch(e){}"\nNov 8 09:28:09 PM  \nNov 8 09:28:10 PM  added 1476 packages from 699 contributors and audited 1477 packages in 31.896s\nNov 8 09:28:11 PM  \nNov 8 09:28:11 PM  225 packages are looking for funding\nNov 8 09:28:11 PM    run `npm fund` for details\nNov 8 09:28:11 PM  \nNov 8 09:28:11 PM  found 1 high severity vulnerability\nNov 8 09:28:11 PM    run `npm audit fix` to fix them, or `npm audit` for details\nNov 8 09:28:20 PM  audited 1477 packages in 8.269s\nNov 8 09:28:21 PM  \nNov 8 09:28:21 PM  225 packages are looking for funding\nNov 8 09:28:21 PM    run `npm fund` for details\nNov 8 09:28:21 PM  \nNov 8 09:28:21 PM  found 1 high severity vulnerability\nNov 8 09:28:21 PM    run `npm audit fix` to fix them, or `npm audit` for details\nNov 8 09:28:30 PM  ==> Using Python version: 3.7.10\nNov 8 09:28:34 PM  ==> Empty build command; skipping build\nNov 8 09:28:46 PM  ==> Uploading build...\nNov 8 09:28:46 PM  ==> Build folder build does not exist!\nNov 8 09:28:46 PM  ==> Build failed \n
Run Code Online (Sandbox Code Playgroud)\n

Jon*_*ton 6

我刚刚遇到了完全相同的问题。原来是因为以下日志:“将警告视为错误,因为 process.env.CI = true。”

我认为这是因为 eslint 返回错误,例如“第 2:8 行:'axios' 已定义但从未使用 no-unused-vars”,因此它阻止构建正确编译。

要修复此问题,请在 Railway 的设置下将构建命令更改为“CI=false npm run build”。这对我有用,尽管我对此很陌生并且不认为这是最佳实践。请有经验的开发人员参与进来!