개인프로젝트/트러블슈팅

빌드 에러. 하나씩 고쳐보기.

자바걸 2024. 5. 10. 00:00

일단 깃헙에 푸시하고 빌드가 실패했다.

엄청 길다.

그래서 아 또 몇일 잡아먹는건가 하고 지레 겁먹었는데, 나름 단번에 해결했다.

구글링만 늘어간다 .ㅠㅠ

Task :npmInstall
29npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@3. I'll try to do my best with it!
30npm WARN @yaireo/tagify@4.26.6 requires a peer of prop-types@>15.5.7 but none is installed. You must install peer dependencies yourself.
31npm WARN @yaireo/tagify@4.26.6 requires a peer of react@* but none is installed. You must install peer dependencies yourself.
32added 10 packages from 56 contributors and audited 10 packages in 1.194s
33npm WARN @yaireo/tagify@4.26.6 requires a peer of react-dom@* but none is installed. You must install peer dependencies yourself.
34found 1 moderate severity vulnerability
35npm WARN bootstrap@5.3.3 requires a peer of @popperjs/core@^2.11.8 but none is installed. You must install peer dependencies yourself.
36 run `npm audit fix` to fix them, or `npm audit` for details
37npm WARN static@1.0.0 No description
38npm WARN static@1.0.0 No repository field.
41> Task :copyFrontLib
43> Task :compileJava
44/home/runner/work/MoUnWan/MoUnWan/src/main/java/com/mounwan/moudules/Account.java:42: warning: @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. If it is not supposed to be settable during building, make the field final.
45 private boolean gatheringCreatedByWeb = true;
46 ^
47/home/runner/work/MoUnWan/MoUnWan/src/main/java/com/mounwan/moudules/Account.java:46: warning: @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. If it is not supposed to be settable during building, make the field final.
48 private boolean gatheringEnrollmentResultByWeb = true;
49 ^
50/home/runner/work/MoUnWan/MoUnWan/src/main/java/com/mounwan/moudules/Account.java:50: warning: @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. If it is not supposed to be settable during building, make the field final.
51 private boolean gatheringUpdatedByWeb = true;
52 ^
53/home/runner/work/MoUnWan/MoUnWan/src/main/java/com/mounwan/moudules/Account.java:53: warning: @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. If it is not supposed to be settable during building, make the field final.
54 private Set<Categories> categories = new HashSet<>();
55 ^
564 warnings
59FAILURE: Build failed with an exception.
61* What went wrong:
62A problem was found with the configuration of task ':processResources' (type 'ProcessResources').
63 - Gradle detected a problem with the following location: '/home/runner/work/MoUnWan/MoUnWan/src/main/resources'.
64> Task :processResources FAILED
66 Reason: Task ':processResources' uses this output of task ':npmInstall' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
68 Possible solutions:
69 1. Declare task ':npmInstall' as an input of ':processResources'.
70 2. Declare an explicit dependency on ':npmInstall' from ':processResources' using Task#dependsOn.
71 3. Declare an explicit dependency on ':npmInstall' from ':processResources' using Task#mustRunAfter.
75* Try:
76> Run with --stacktrace option to get the stack trace.
77> Run with --info or --debug option to get more log output.
78> Run with --scan to get full insights.
80* Get more help at https://help.gradle.org
82BUILD FAILED in 27s
836 actionable tasks: 5 executed, 1 up-to-date
84Error: Process completed with exit code 1.

일단 위처럼 긴 내용이 나와서 빌드에 실패했다.

여기서 잠깐, 갑자기 빌드와 컴파일의 차이를 정확히 알고싶어졌다.

-> 💡빌드와 컴파일 차이

 


여튼 빌드 중 긴 에러와 경고가 나왔고, 심지어 여러개였다.

자잘한 에러들이지만 이런거에 막히면 수일을 잡아먹는다고...ㅠ

일단 정리해보겠다.

🔴경고 1. npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@3. I'll try to do my best with it!

내용 :  현재 사용중인 npm버전이 package-lock.json파일의 버전과 호환이 안맞는다는 것이었다.

해결 : npm을 최신 버전으로 업데이트 했다. 

 

🔴 경고 2. npm WARN @yaireo/tagify@4.26.6 requires a peer of prop-types@>15.5.7 but none is installed. You must install peer dependencies yourself.
npm WARN @yaireo/tagify@4.26.6 requires a peer of react@* but none is installed. You must install peer dependencies yourself.
npm WARN @yaireo/tagify@4.26.6 requires a peer of react-dom@* but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@5.3.3 requires a peer of @popperjs/core@^2.11.8 but none is installed. You must install peer dependencies yourself.

내용 : peer dependency를 설치하라는 내용이다.


이를 해결하기 위해서는 호스트 패키지 간의 이러한 '종속성'을 표현해야 한다. 패키지 매니저에게, '나는 내 호스트 패키지 버전 1.2.x에 연결될 때만 작동하므로 나를 설치하는 경우 호환되는 호스트가 설치되어있는지 확인해주세요' 라고 말해야 하는데, 이 관계를 peer dependency라고 한다.

dependency는 내가 만든 모듈에서 사용하는 패키지들을 지정하는 반면, peer dependency는 반대로 내가 만든 모듈이 다른 모듈과 함께 동작할 수 있다는 호환성을 표시하는 것이다. 내가 만든 모듈이 호스트의 모든 버전이 아니라 1.3 버전과만 동작한다면, 그런 정보를 표시해줘야 하는데 이럴 때 사용하는 것이 peerDependencies라는 것이다.
🔗참고 : https://bohyeon-n.github.io/deploy/etc/peerdependencies.html

 

🔴경고3. found 1 moderate severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details

내용 : 취약성 경고이다. npm이 제공하는 자동수정명령을 사용하라고 한다.

해결 : npm audit fix 명령으로 자동수정명령을 사용했다.

🔴에러 1. Reason: Task ':processResources' uses this output of task ':npmInstall' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

Possible solutions:
  1. Declare task ':npmInstall' as an input of ':processResources'.
  2. Declare an explicit dependency on ':npmInstall' from ':processResources' using Task#dependsOn.
  3. Declare an explicit dependency on ':npmInstall' from ':processResources' using Task#mustRunAfter.

Please refer to https://docs.gradle.org/8.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.

내용 : build.gradel에서 :processResources 작업이 npmInstall작업 출력을 사용하지만, 두 작업간의 종속성이 명시적으로 정의되지 않아 생기는 문제이다.  

해결:  build.gradel에서  명시적으로 의존하도록 설정했다. 

processResources.dependsOn npmInstall

 

 

이렇게 나름 금방 해결됐다.