0
votes

I have a problem with npm install java command from Windows cmd.

Path to my include file 'jni.h' is in INCLUDE variable in Windows Environment Variables. File 'jni.h' located in C:\Program Files\Java\jdk-15.0.2\include

INCLUDE variable looks like: C:\Program Files\Java\jdk-15.0.2\include C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include C:\Program Files\Java\jdk-15.0.2\include\win32

Path variable looks like: C:\Program Files\Java\jdk-15.0.2 C:\Program Files (x86)\Windows Kits\8.1 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\Hostx64\x64 C:\Program Files\Java\jdk-15.0.2\include

Complete log:

D:\helloworld>npm i java

[email protected] install D:\helloworld\node_modules\java node-gyp rebuild

D:\helloworld\node_modules\java>if not defined npm_config_node_gyp (node "D:\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "D:\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Projects are built sequentially in this solution. To enable parallel build, add the parameter "-m".  java.cpp
  javaObject.cpp
  javaScope.cpp
  methodCallBaton.cpp
D:\helloworld\node_modules\java\src\javaScope.h(5,10): fatal error C1083: Cannot open include file: 'jni.h': No such file or directory (compiling source file ..\src\javaScope.cpp) [D:\helloworld\node_modules\java\build\nodejavabridge_bindings.vcxproj]
D:\helloworld\node_modules\java\src\utils.h(7,10): fatal error C1083: Cannot open include file: 'jni.h': No such file or directory (compiling source file ..\src\methodCallBaton.cpp) [D:\helloworld\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  nodeJavaBridge.cpp
  utils.cpp
D:\helloworld\node_modules\java\src\java.h(7,10): fatal error C1083: Cannot open include file: 'jni.h': No such file or directory (compiling source file ..\src\java.cpp) [D:\helloworld\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  win_delay_load_hook.cc
D:\helloworld\node_modules\java\src\javaObject.h(7,10): fatal error C1083: Cannot open include file: 'jni.h': No such f
ile or directory (compiling source file ..\src\javaObject.cpp) [D:\helloworld\node_modules\java\build\nodejavabridge_bi
ndings.vcxproj]
D:\helloworld\node_modules\java\src\utils.h(7,10): fatal error C1083: Cannot open include file: 'jni.h': No such file or directory (compiling source file ..\src\utils.cpp) [D:\helloworld\node_modules\java\build\nodejavabridge_bindings.vcx
proj]
D:\helloworld\node_modules\java\src\java.h(7,10): fatal error C1083: Cannot open include file: 'jni.h': No such file or directory (compiling source file ..\src\nodeJavaBridge.cpp) [D:\helloworld\node_modules\java\build\nodejavabridge_bind
ings.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (D:\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\helloworld\node_modules\java
gyp ERR! node -v v12.20.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
1

1 Answers

0
votes

Solved by:

  1. Creating JAVA_HOME variable in system variables
  2. Adding JDK path to JAVA_HOME variable
  3. Adding %JAVA_HOME%\bin to PATH (user variable)