简体   繁体   中英

npm java package not getting installed

npm Java package is not getting installed. Been trying this over a week now, but no success.
I have installed the Visual Studio Express 2013 for Windows .
I also have Python v2.7 installed.
Current Java version in my regedit is set to 1.7 .
Before installing I did an npm config set msvs_version 2013 , then I did npm install java and it threw error:

> java@0.7.2 install C:\Users\1060641\AppData\Roaming\npm\node_modules\java
> node-gyp rebuild

C:\Users\1060641\AppData\Roaming\npm\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 )
C:\Users\1060641\AppData\Roaming\npm\node_modules\java\build\binding.sln : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed, either 1) install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual Studio 2008.
gyp ERR! build error
gyp ERR! stack Error: `msbuild` 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:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\1060641\AppData\Roaming\npm\node_modules\java
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
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 v0.12.7
npm ERR! npm  v2.11.3
npm ERR! code ELIFECYCLE

npm ERR! java@0.7.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the java@0.7.2 install script 'node-gyp rebuild'.
npm ERR! 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 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\1060641\Desktop\test\npm-debug.log

Then I did npm install --msvs_version=2013 .
It again threw error:

C:\Users\1060641\Desktop\test>npm install --msvs_version=2013
npm ERR! install Couldn't read dependencies
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" "--msvs_version=2013"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! path C:\Users\1060641\package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno -4058

npm ERR! package.json ENOENT, open 'C:\Users\1060641\package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\1060641\Desktop\test\npm-debug.log

Then again I did npm install java --msvs_version=2013 --global .
Again there was an error:

C:\Users\1060641\Desktop\test>npm install java --msvs_version=2013 --global
/
> java@0.7.2 install C:\Users\1060641\AppData\Roaming\npm\node_modules\java
> node-gyp rebuild


C:\Users\1060641\AppData\Roaming\npm\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 )
C:\Users\1060641\AppData\Roaming\npm\node_modules\java\build\binding.sln : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed, either 1) install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual Studio 2008.
gyp ERR! build error
gyp ERR! stack Error: `msbuild` 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:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\1060641\AppData\Roaming\npm\node_modules\java
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
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" "--msvs_version=2013" "--global"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! code ELIFECYCLE

npm ERR! java@0.7.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the java@0.7.2 install script 'node-gyp rebuild'.
npm ERR! 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 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\1060641\Desktop\test\npm-debug.log

I wonder what is going wrong.
I am using node version 0.12.7
And the node-gym version I installed was the latest. And in the error log some line reads:

gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok

I do not wish to upgrade my NodeJS version since its he version that our client wants us to use.
Please help!

Found a fix.
Sometimes the msvs_version parameter is not set properly.
Did an npm config list to check the value of msvs_version .
It showed 2015 . Changed it: npm config set msvs_version 2013 and checked for the values again: npm config list .
Installed one more package Microsoft Build tool 2013 . This is compatible with Visual Studio 2013 Express .
After that set the path for MSBuild.exe in User Environment Variable as well as System Environment Variable . For me the path was C:\\Program Files\\MSBuild\\12.0\\Bin . Append this path starting with a ";" ie ;C:\\Program Files\\MSBuild\\12.0\\Bin .
Now run npm install java . It should work.

Here is my solution for the same kind of issue that I was facing... This should work.

run

in administrator privileged command prompt window

npm install -g node-gyp
npm install --global --production windows-build-tools 
npm update 
npm install java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM