npm install fails with error C2373 with vs2015 update 3 - node.js

After reinstalling my machine with windows 10, setting it up with Visual Studio 2015 I encountered this error on installing my git repositories:
→ npm install fails on different projects with:
...
C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_load_hook.c(34): error C2373: "__pfnDliNotifyHook2": [...]
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:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10586
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\...\node_modules\buffertools
gyp ERR! node -v v4.4.7
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok

This error stays in relation with npm, node-gyp and Visual Studio 2015 and is already fixed in node-gyp#3.4.0, but npm is still pointing to an old version. As I workaround I can propose this:
Go to your folder where npm is installed, e.g.:
C:\Program Files\nodejs\node_modules\npm
Open: package.json
Remove entry for node-gyp in bundleDependencies
Bump version number to 3.4.0 for node-gyp in dependencies
Make a npm i in this directory to install node-gyp#3.4.0 to fix the problem
Relating GitHub issues can be found here:
nodejs/node#7286
nodejs/node-gyp#956
npm/npm#13199
npm/npm#13200

Or update npm:
npm install npm -g

An alternative solution that doesn't involve messing with npm installation is to run
SET CL=-DDELAYIMP_INSECURE_WRITABLE_HOOKS %CL%
before running npm install

Related

How to install packages for a NodeJs Blockchain Project

I wanted to install a NodeJs Blockchain project locally. On installing the dependencies in the node, I am getting these error constantly
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.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:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.18362
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 E:\Projects\blockchain\blockchain-verification-new\node_modules\contextify
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
I tried many things like updating visual studio and it's all components but couldn't succeed. Can anyone help?
Run the following command npm i -g windows-build-tools, it will install python and other required components
Also try to update your npm config (change paths to your versions):
npm config set python python2.7 --global
npm config set python C:\Python27\python.exe --global
npm config set msvs_version 2015 --global
npm config set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140

Unable to install tensorflow.js

I am trying to install tensorflow.js on a windows machine using:
npm install #tensorflow/tfjs-node-gpu
I am using python 2.7 and have tried updating npm.
Whenever I do that I get the following error:
Error: node-gyp rebuild failed with: Error: Command failed: node-gyp rebuild
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.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:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:189:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.17134
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:\Coding\AI\node_modules\#tensorflow\tfjs-node-gpu
gyp ERR! node -v v10.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
I ran into the same problem on Mac. This issue on github points out that when you use this package node-gyp (which I think is a cross-platform tool used to help install Tensorflow), you need to make sure that your file path doesn't contain any spaces.
So, based on your error message, it looks like you are trying to install tensorflow in a project that is in the Program Files\ folder. node-gyp doesn't like that because you have spaces in the name. It's kind of annoying, but I fixed the problem by putting my node project in a folder without spaces, i.e. /Users/Bryce/Coding-Projects/MyProject/
This worked for me:
npm install #tensorflow/tfjs
You update npm package first:
npm update
And upgrade:
npm upgrade

Compiling native node module with npm i fails, works with node-gyp rebuild

I'm trying to compile a native node module using
npm i
This fails with error
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:305:16)
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.14393
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:\bitbucket\node\native_modules
gyp ERR! node -v v6.10.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
However, if I run the node-gyp command manually with
node-gyp rebuild
Then it works fine.
I notice that node-gyp --version returns v3.6.0 whereas in the error message above it's running v3.4.0.
How do I update npm to use the newer version (which seems to work ok)?
Also, why would this be failing on the old version?
I tried the instructions here https://github.com/nodejs/node-gyp/wiki/Updating-npm's-bundled-node-gyp they don't seem to work. I'm on Windows 10.
I have this working now. Here's what I did:
Open a command prompt (run as administrator). cd to the node installation folder, then run:
C:\Program Files\nodejs\node_modules\npm>npm uninstall node-gyp --save
C:\Program Files\nodejs\node_modules\npm>npm install node-gyp --save

how to solve npm install command

i want to learn node js and my boss send me this project but its show error. how to solve this type of problem when i enter npm install this command is show below error...i already installed visual studio 2015
gyp ERR! stack operable program or batch file.
gyp ERR! stack
gyp ERR! stack Can't find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2008+ installed?
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:134:25
gyp ERR! stack at ChildProcess.exithandler (child_process.js:213:5)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at maybeClose (internal/child_process.js:877:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
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 D:\Addi\HeavyMetalServer\node_modules\iltorb
gyp ERR! node -v v6.9.2
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
Your npm install command fails during installing node-gyp module. node-gyp module gives a lot of problems when installing on windows. You can run this command to install its dependencies first - npm install --global --production windows-build-tools . This command is given on their github page.
For windows users:
Try running the npm install command from Powershell with administrative rights
This is one of the many workarounds

NodeJS 5 errors while installing npm packages

Since I installed node 5.0.0, I start getting errors while installing most of npm packages.
it never happened before when I had node 4.x.
after
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Program Files\Python27\python.exe", you can set the PYTHON env variable.
gyp ERR! stack at failNoPython (c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:116:14)
gyp ERR! stack at c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:71:11
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 10.0.10240
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\Murhaf\AppData\Roaming\npm\node_modules\ember-cli\node_modules\bufferutil
gyp ERR! node -v v5.0.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm ERR! Windows_NT 10.0.10240
basically there's 2 main errors.
The first is asking for python.
The second is asking for .Net SDK 2.0.
after getting python 2.7.10 installed the first error disappeared. but I couldn't pass the MSbuild.exe error even after installing .Net SDK.
Is this happening with everyone?
Do I have to install Visual Studio to get node.js and NPM to work?
I prefer not to. Any alternative way?
I tried a clean installation, restarted my PC and installed it again, same errors.
Update
Now I installed both Python and VS2015, the previous errors are gone but I have this error
c:\Users\Murhaf\Desktop\sage\node_modules\bufferutil\build\bufferutil.vcxproj(20,3): error MSB4019: The imported projec
t "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Default.props" was not found. Confirm that the
path in the <Import> declaration is correct, and that the file exists on disk.
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:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10240
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\Murhaf\Desktop\sage\node_modules\bufferutil
gyp ERR! node -v v5.0.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:bufferutil bufferutil#1.2.1 install: `node-gyp rebuild`
npm WARN install:bufferutil Exit status 1
you need Visual Studio and Python to install modules with binary components on windows, which probably means the module you are trying to install has binary components, so try to install it after Visual studio and Python.
npm install --msvs_version=2013 should work.
I am having problems with VS2015, too.

Resources