简体   繁体   English

使用 npm 安装 java package 时出错 无法打开包含文件:'jni.h' 没有这样的文件或目录

[英]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.我对来自 Windows ZDFFF0A7FA1A55C8C1A2966C19F64DA 的npm 安装 java命令有疑问。

Path to my include file 'jni.h' is in INCLUDE variable in Windows Environment Variables.我的包含文件“jni.h”的路径位于 Windows 环境变量中的 INCLUDE 变量中。 File 'jni.h' located in C:\Program Files\Java\jdk-15.0.2\include文件“jni.h”位于 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 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 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 D:\helloworld>npm i java

java@0.12.1 install D:\helloworld\node_modules\java node-gyp rebuild java@0.12.1 安装 D:\helloworld\node_modules\java node-gyp 重建

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! java@0.12.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the java@0.12.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Solved by:解决者:

  1. Creating JAVA_HOME variable in system variables在系统变量中创建 JAVA_HOME 变量
  2. Adding JDK path to JAVA_HOME variable将 JDK 路径添加到 JAVA_HOME 变量
  3. Adding %JAVA_HOME%\bin to PATH (user variable)将 %JAVA_HOME%\bin 添加到 PATH(用户变量)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未找到 jni.h 文件 - 在 OS X El Capitan 上安装 node-java 模块 - jni.h file not found - installing node-java module on OS X El Capitan 安装全局 npm 包后出现“错误:ENOENT:没有这样的文件或目录” - "Error: ENOENT: no such file or directory" after installing global npm package 在npm注册表中安装我发布的软件包时出错-Errorno-4058。没有这样的文件或目录main.js错误 - Error installing my published package in npm registry - Errorno - 4058. No such file or directory main.js error 使用 npm 而不是 yarn 安装包时出错 - Error installing package using npm instead of yarn npm-bundle 失败并出现错误:ENOENT:没有这样的文件或目录,打开“package.json” - npm-bundle fails with Error: ENOENT: no such file or directory, open 'package.json' NodeJS-无法打开包含文件:“ unistd.h”: - NodeJS - Cannot open include file: 'unistd.h': 使用 npm 安装 ply 时未获取此类文件或目录 - Getting no such file or directory while installing ply using npm NPM 启动错误 - 文件路径找不到 JSON 包文件 - NPM start error - file path cannot find JSON package file 使用 npm 安装 live-server 包时出错。 `npm audit` 无助于解决问题 - Getting error while installing live-server package using npm. `npm audit` is not helping to fix the problem 安装自己的npm软件包时出现Metro Bundler错误 - Metro Bundler error in installing own npm package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM