Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
599 views
in Technique[技术] by (71.8m points)

javascript - error installing java package using npm Cannot open include file: 'jni.h' No such fi le or directory

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 FilesJavajdk-15.0.2include

INCLUDE variable looks like: C:Program FilesJavajdk-15.0.2include C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.28.29333include C:Program FilesJavajdk-15.0.2includewin32

Path variable looks like: C:Program FilesJavajdk-15.0.2 C:Program Files (x86)Windows Kits8.1 C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.28.29333inHostx64x64 C:Program FilesJavajdk-15.0.2include

Complete log:

D:helloworld>npm i java

[email protected] install D:helloworld ode_modulesjava node-gyp rebuild

D:helloworld
ode_modulesjava>if not defined npm_config_node_gyp (node "D:
odejs
ode_modules
pm
ode_modules
pm-lifecycle
ode-gyp-bin\....
ode_modules
ode-gypin
ode-gyp.js" rebuild )  else (node "D:
odejs
ode_modules
pm
ode_modules
ode-gypin
ode-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
ode_modulesjavasrcjavaScope.h(5,10): fatal error C1083: Cannot open include file: 'jni.h': No such file or directory (compiling source file ..srcjavaScope.cpp) [D:helloworld
ode_modulesjavauild
odejavabridge_bindings.vcxproj]
D:helloworld
ode_modulesjavasrcutils.h(7,10): fatal error C1083: Cannot open include file: 'jni.h': No such file or directory (compiling source file ..srcmethodCallBaton.cpp) [D:helloworld
ode_modulesjavauild
odejavabridge_bindings.vcxproj]
  nodeJavaBridge.cpp
  utils.cpp
D:helloworld
ode_modulesjavasrcjava.h(7,10): fatal error C1083: Cannot open include file: 'jni.h': No such file or directory (compiling source file ..srcjava.cpp) [D:helloworld
ode_modulesjavauild
odejavabridge_bindings.vcxproj]
  win_delay_load_hook.cc
D:helloworld
ode_modulesjavasrcjavaObject.h(7,10): fatal error C1083: Cannot open include file: 'jni.h': No such f
ile or directory (compiling source file ..srcjavaObject.cpp) [D:helloworld
ode_modulesjavauild
odejavabridge_bi
ndings.vcxproj]
D:helloworld
ode_modulesjavasrcutils.h(7,10): fatal error C1083: Cannot open include file: 'jni.h': No such file or directory (compiling source file ..srcutils.cpp) [D:helloworld
ode_modulesjavauild
odejavabridge_bindings.vcx
proj]
D:helloworld
ode_modulesjavasrcjava.h(7,10): fatal error C1083: Cannot open include file: 'jni.h': No such file or directory (compiling source file ..src
odeJavaBridge.cpp) [D:helloworld
ode_modulesjavauild
odejavabridge_bind
ings.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildCurrentBinMSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (D:
odejs
ode_modules
pm
ode_modules
ode-gyplibuild.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
ode_modulesjava
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.
question from:https://stackoverflow.com/questions/65898949/error-installing-java-package-using-npm-cannot-open-include-file-jni-h-no-suc

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Solved by:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...