我正在尝试在我的NodeJS项目中安装java模块。但我得到以下错误无法弄清楚这里有什么问题。任何人都可以指导我如何解决这个问题。我使用的是Windows 7 64位操作系统。我的PC中安装了Microsoft Visual Studio 2015 Professional和MS VC ++ Redistributable x86 14.0.xxx15。
我正在使用python2.7,jdk 1.8.0_101(oracle jdk)。
"C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" install java
Standard error:
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 2148734720
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 6.1.7601
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\cdac\Desktop\SmartBin\Server\node_modules\java
gyp ERR! node -v v6.10.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! Windows_NT 6.1.7601
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.10.0
npm ERR! npm v3.10.10
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\cdac\Desktop\SmartBin\Server\npm-debug.log
Standard output:
> java@0.8.0 install C:\Users\cdac\Desktop\SmartBin\Server\node_modules\java
> node-gyp rebuild
C:\Users\cdac\Desktop\SmartBin\Server\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 )
Process finished with exit code 1
答案 0 :(得分:0)
我认为问题在于node-gyp命令。 尝试安装最新版本的node-gyp。 首先转到安装node.exe的位置。要在命令提示符中找到它,请运行:
$where node
现在cd到包含node.exe的目录,最后是node_modules \ npm。即。
$ cd "C:\Program Files\nodejs\node_modules\npm"
现在你终于可以运行:
$ npm install -g node-gyp@latest
此后再次尝试运行npm java来安装java模块。 我希望这有帮助 :) 以防万一在运行上述命令之前,通过将cd安装到安装并运行节点的位置来安装最新版本的节点 :(注意 - 以管理员身份打开命令提示符)
npm install npm@latest