reactjs 铁路部署时构建失败

nc1teljy  于 2022-12-29  发布在  React
关注(0)|答案(1)|浏览(288)

我目前正尝试在Railway上部署一个简单的Notes应用程序,这是课程挑战的一部分。问题是当我尝试部署它时,我得到了以下消息:

#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 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
 
#11 14.98 npm WARN deprecated svgo@1.3.2: 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 > notes@0.1.0 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`

我也试着在www.example.com上部署它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  > core-js@3.26.0 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  > core-js-pure@3.26.0 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 😞
qkf9rpyu

qkf9rpyu1#

我刚刚遇到了完全相同的问题。原来是因为下面的日志:'将警告视为错误,因为process.env.CI = true。'
我认为这是因为eslint返回错误,如“Line 2:8:定义了“axios”,但从未使用过“no-unused-vars”,因此它会阻止生成正确编译。
要解决这个问题,请在Railway的设置下将您的构建命令更改为“CI=false npm run build”。这对我来说很有效,尽管我是新手,不认为这是最好的做法。请感觉到有经验的开发人员的配合!

相关问题