npm install fails with error C2373 with vs2015 update 3

11,401

Solution 1

This error stays in relation with npm, node-gyp and Visual Studio 2015 and is already fixed in [email protected], but npm is still pointing to an old version. As I workaround I can propose this:

  1. Go to your folder where npm is installed, e.g.: C:\Program Files\nodejs\node_modules\npm

  2. Open: package.json

  3. Remove entry for node-gyp in bundleDependencies

  4. Bump version number to 3.4.0 for node-gyp in dependencies

  5. Make a npm i in this directory to install [email protected] to fix the problem

Relating GitHub issues can be found here:

  1. nodejs/node#7286
  2. nodejs/node-gyp#956
  3. npm/npm#13199
  4. npm/npm#13200

Solution 2

Or update npm:

npm install npm -g

Solution 3

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

Share:
11,401
Beat
Author by

Beat

#SOreadytohelp

Updated on June 14, 2022

Comments

  • Beat
    Beat about 2 years

    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
    
  • Admin
    Admin almost 8 years
    When you say "Dump entry", do you mean add, or remove?
  • Admin
    Admin almost 8 years
    I didn't remove it, but the fix still worked. Do I still need to remove it? Thanks! You might want to change the wording of your reply for the benefit any non-native English speakers and ditsy native English speakers.
  • Beat
    Beat almost 8 years
    It was for sake of completeness
  • Mike 'Pomax' Kamermans
    Mike 'Pomax' Kamermans almost 8 years
    Note that in a "normal" windows install you will need UAC access to this file, which may require starting an editor and a terminal with the "run as administrator" option, or you won't be able to save the file or run npm install
  • Loghorn
    Loghorn almost 8 years
    Are you issuing the SET command just before running npm install, in the same command prompt instance?
  • Mikalai
    Mikalai almost 8 years
    Yes, I set CL variable before npm install, after that another issue was
  • Erik Vullings
    Erik Vullings almost 8 years
    Thanks for the tip! (just had to remove the trailing %CL%) ` SET CL=-DDELAYIMP_INSECURE_WRITABLE_HOOKS `
  • Brian Clifton
    Brian Clifton almost 8 years
    I've had to also run this to get it working: npm install -g rimraf
  • Gabriel Matusevich
    Gabriel Matusevich almost 8 years
    Showed some errors in my console but it worked :p windows is so messy
  • Graham
    Graham almost 8 years
    Although I like the new output format this gave me, it didn't get rid of the error.
  • 1mike12
    1mike12 over 7 years
    also, make sure you use windows powershell for the npm install or amdinistrator mode because it will fail otherwise
  • JHH
    JHH over 7 years
    Using git bash on windows I used export CL=-DDELAYIMP_INSECURE_WRITABLE_HOOKS successfully (although my build of ursa still failed, node-gyp on windows is a pain)