Inflearn brand logo image

인프런 커뮤니티 질문&답변

godmercury님의 프로필 이미지
godmercury

작성한 질문수

[개정3판] Node.js 교과서 - 기본부터 프로젝트 실습까지

npm install java 설치 오류 문의

작성

·

1.3K

·

수정됨

0

안녕하세요.

node.js에서 java의 jar파일을 불러서 실행시키고 싶어서 java 모듈을 설치했습니다. (npm install java)

그런데 아래 처럼 설치 오류가 나와서 어떻게 해야할지 모르겠습니다. 방법이 있다면 알려주시면 좋겠습니다.

npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
npm ERR! code 1
npm ERR! path C:\workspace\test\node_modules\java
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.3.1
npm ERR! gyp info using node@18.16.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.11.3 found at "C:\Python311\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS checking VS2019 (16.11.33529.622) found at:
npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features"
npm ERR! gyp ERR! find VS - found VC++ toolset: v142
npm ERR! gyp ERR! find VS - missing any Windows SDK
npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack     at VisualStudioFinder.fail (C:\workspace\test\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
npm ERR! gyp ERR! stack     at C:\workspace\test\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\workspace\test\node_modules\node-gyp\lib\find-visualstudio.js:369:14)
npm ERR! gyp ERR! stack     at C:\workspace\test\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack     at C:\workspace\test\node_modules\node-gyp\lib\find-visualstudio.js:390:16
npm ERR! gyp ERR! stack     at C:\workspace\test\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack     at C:\workspace\test\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:427:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
npm ERR! gyp ERR! System Windows_NT 10.0.19045
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\workspace\\test\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\workspace\test\node_modules\java
npm ERR! gyp ERR! node -v v18.16.0
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\yeeun\AppData\Local\npm-cache\_logs\2023-06-07T07_26_56_717Z-debug-0.log

 

오류를 해결하고자 참조한 링크입니다.

  1. https://yuhe-dogspaw.tistory.com/19

  2. https://velog.io/@wjs4199/React-npm-install%EC%8B%9C-node-gyp-%EC%97%90%EB%9F%AC

  3. https://www.npmjs.com/package/node-gyp

     

다음과 같은 시도를 해보았지만 모두 실패 했습니다.

해결 시도 1.

  1. python 2.x로 다운그레이드

  2. visual studio 2019 설치

  3. 관리자모드 명령프롬프트에서 다음 2개 설치

    1. npm install --global node-gyp

    2. npm install --global --production windows-build-tools

  4. 실패 ㅜㅜ

해결 시도2.

  1. npm install -g node-gyp

  2. node-gyp rebuild --python "파이썬 2.x 설치 경로"

  3. npm config set python "파이썬 2.x 설치 경로"

  4. 실패 ㅜㅜ

 

그리고, 혹시 jar 파일 말고 class 파일을 실행시키는 방법도 있을까요?

const java = require('java');
java.classpath.push('jar/test.jar');
const something = java.import('com.house.test.Test');
const instance = new something();

const message = '테스트트트';
instance.fnSync(message);

이렇게 사용을 하고 있는데 class 파일로도 실행할 수 있으면 좋겠습니다.

 

개발pc : window 10 home

node.js 버전 : 18.16 (msi로 설치할 때 강의 초반에 말씀하신 체크박스를 체크하고 설치함)

python 버전 : 3.11

  • 참고로 window 11 home 혹은 window 10 pro 에서는 설치가 잘 되었습니다.

 

답변 1

0

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

노드에서 왜 자바 파일을 직접 실행해야 하나요? 자바로 서버를 만들어서 api 호출하시가나 명령어로 만들어서 shell 스크립트 호출하세요

섹션3 child_process 시간에 shell 호출 알려드렸습니다

godmercury님의 프로필 이미지
godmercury
질문자

java가 아닌 다른 모듈을 설치할 때에는 저 위의 오류가 나올 확률은 낮은가요? 다른 모듈을 설치할 때 비슷한 오류가 나면 어떻게 해결해야 하는지 궁금합니다.

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

저건 node.js를 다른 언어와 연결해야할 때 발생하는 문제입니다. 저 문제가 발생하면 저도 에러메시지로 검색해서 찾아보는 수밖에 없습니다. 비슷한 경우로 bcrypt를 설치할 때 저런 유형의 문제가 발생하기도 합니다. 자바스크립트만 사용하는 모듈을 쓸 때는 저 에러가 발생하지 않습니다.

godmercury님의 프로필 이미지
godmercury
질문자

그렇군요. 답변 감사합니다.^^

godmercury님의 프로필 이미지
godmercury

작성한 질문수

질문하기