如何解决在Windows 10上安装节点-java时发生LNK 2001错误?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (319)

在安装时出现以下错误:

C:\Users\seven\workspace\silver\deployments\apps\electron-quick-start>java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) Client VM (build 25.121-b13, mixed mode, sharing)

C:\Users\seven\workspace\silver\deployments\apps\electron-quick-start>npm --version
3.10.8

node-gyp@3.5.0
node@6.9.1

C:\Users\seven\workspace\silver\deployments\apps\electron-quick-start>npm install java

> java@0.8.0 install C:\Users\seven\workspace\silver\deployments\apps\electron-quick-start\node_modules\java
> node-gyp rebuild


C:\Users\seven\workspace\silver\deployments\apps\electron-quick-start\node_modules\java>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  java.cpp
  javaObject.cpp
  javaScope.cpp
  methodCallBaton.cpp
  nodeJavaBridge.cpp
  utils.cpp
  win_delay_load_hook.cc
..\src\javaObject.cpp(116): warning C4996: 'v8::Function::NewInstance': was declared deprecated [C:\Users\seven\workspa
ce\silver\deployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  C:\Users\seven\.node-gyp\6.9.1\include\node\v8.h(3274): note: see declaration of 'v8::Function::NewInstance'
..\src\javaObject.cpp(349): warning C4996: 'v8::Function::NewInstance': was declared deprecated [C:\Users\seven\workspa
ce\silver\deployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  C:\Users\seven\.node-gyp\6.9.1\include\node\v8.h(3274): note: see declaration of 'v8::Function::NewInstance'
..\src\utils.cpp(347): warning C4996: 'v8::Value::ToInt32': was declared deprecated [C:\Users\seven\workspace\silver\de
ployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  C:\Users\seven\.node-gyp\6.9.1\include\node\v8.h(8202): note: see declaration of 'v8::Value::ToInt32'
..\src\utils.cpp(354): warning C4996: 'v8::Value::ToNumber': was declared deprecated [C:\Users\seven\workspace\silver\d
eployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  C:\Users\seven\.node-gyp\6.9.1\include\node\v8.h(8166): note: see declaration of 'v8::Value::ToNumber'
..\src\java.cpp(897): warning C4996: 'v8::Value::ToNumber': was declared deprecated [C:\Users\seven\workspace\silver\de
ployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  C:\Users\seven\.node-gyp\6.9.1\include\node\v8.h(8166): note: see declaration of 'v8::Value::ToNumber'
..\src\java.cpp(927): warning C4996: 'v8::Value::ToNumber': was declared deprecated [C:\Users\seven\workspace\silver\de
ployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  C:\Users\seven\.node-gyp\6.9.1\include\node\v8.h(8166): note: see declaration of 'v8::Value::ToNumber'
..\src\java.cpp(956): warning C4996: 'v8::Value::ToNumber': was declared deprecated [C:\Users\seven\workspace\silver\de
ployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  C:\Users\seven\.node-gyp\6.9.1\include\node\v8.h(8166): note: see declaration of 'v8::Value::ToNumber'
..\src\java.cpp(983): warning C4996: 'v8::Value::ToNumber': was declared deprecated [C:\Users\seven\workspace\silver\de
ployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  C:\Users\seven\.node-gyp\6.9.1\include\node\v8.h(8166): note: see declaration of 'v8::Value::ToNumber'
..\src\java.cpp(1019): warning C4996: 'v8::Value::ToNumber': was declared deprecated [C:\Users\seven\workspace\silver\d
eployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  C:\Users\seven\.node-gyp\6.9.1\include\node\v8.h(8166): note: see declaration of 'v8::Value::ToNumber'
..\src\java.cpp(1044): warning C4996: 'v8::Value::ToNumber': was declared deprecated [C:\Users\seven\workspace\silver\d
eployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  C:\Users\seven\.node-gyp\6.9.1\include\node\v8.h(8166): note: see declaration of 'v8::Value::ToNumber'
..\src\utils.cpp(969): warning C4996: 'v8::Object::GetHiddenValue': was declared deprecated [C:\Users\seven\workspace\s
ilver\deployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  C:\Users\seven\.node-gyp\6.9.1\include\node\v8.h(2956): note: see declaration of 'v8::Object::GetHiddenValue'
..\src\utils.cpp(973): warning C4996: 'v8::Object::SetHiddenValue': was declared deprecated [C:\Users\seven\workspace\s
ilver\deployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  C:\Users\seven\.node-gyp\6.9.1\include\node\v8.h(2954): note: see declaration of 'v8::Object::SetHiddenValue'
..\src\utils.cpp(977): warning C4996: 'v8::Object::SetHiddenValue': was declared deprecated [C:\Users\seven\workspace\s
ilver\deployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  C:\Users\seven\.node-gyp\6.9.1\include\node\v8.h(2954): note: see declaration of 'v8::Object::SetHiddenValue'
c:\users\seven\workspace\silver\deployments\apps\electron-quick-start\node_modules\nan\nan_new.h(214): warning C4267: '
argument': conversion from 'size_t' to 'int', possible loss of data (compiling source file ..\src\utils.cpp) [C:\Users\
seven\workspace\silver\deployments\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
  ..\src\utils.cpp(750): note: see reference to function template instantiation 'v8::MaybeLocal<v8::String> Nan::New<v8
  ::String,const _Elem*,unsigned __int64>(A0,std::A1)' being compiled
          with
          [
              _Elem=char,
              A0=const char *,
              A1=unsigned __int64
          ]
     Creating library C:\Users\seven\workspace\silver\deployments\apps\electron-quick-start\node_modules\java\build\Rel
  ease\nodejavabridge_bindings.lib and object C:\Users\seven\workspace\silver\deployments\apps\electron-quick-start\nod
  e_modules\java\build\Release\nodejavabridge_bindings.exp
java.obj : error LNK2001: unresolved external symbol __imp_JNI_CreateJavaVM [C:\Users\seven\workspace\silver\deployment
s\apps\electron-quick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
C:\Users\seven\workspace\silver\deployments\apps\electron-quick-start\node_modules\java\build\Release\nodejavabridge_bi
ndings.node : fatal error LNK1120: 1 unresolved externals [C:\Users\seven\workspace\silver\deployments\apps\electron-qu
ick-start\node_modules\java\build\nodejavabridge_bindings.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.14986
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\seven\workspace\silver\deployments\apps\electron-quick-start\node_modules\java
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm ERR! Windows_NT 10.0.14986
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "java"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE

npm ERR! java@0.8.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the java@0.8.0 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the java package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs java
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls java
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\seven\workspace\silver\deployments\apps\electron-quick-start\npm-debug.log
提问于
用户回答回答于
用户回答回答于

NPM将其安装在32位架构中:

npm install java --arch=ia32

扫码关注云+社区

领取腾讯云代金券