The npm install command in Node.js encounters an error C2373 when used in conjunction with Visual Studio 2015 Update 3. Rewrite this sentence and simply return it rewritten without any additional text.

62👍

This error is related to npm, node-gyp, and Visual Studio 2015, and it has already been fixed in node-gyp@3.4.0. However, npm is still using an older version. Here is a workaround that you can follow:

  1. Go to the folder where npm is installed, for example:
    C:\Program Files\nodejs\node_modules\npm
  2. Open the file package.json
  3. Remove the entry for node-gyp in the bundleDependencies section
  4. Increase the version number of node-gyp to 3.4.0 in the dependencies section
  5. Run npm i in this directory to install node-gyp@3.4.0 and fix the problem

Related GitHub issues can be found here:

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

19👍

To update npm, you can use the following command:

npm install npm -g

16👍

An alternative solution that avoids modifying the npm installation process is to execute the following command before running npm install:

SET CL=-DDELAYIMP_INSECURE_WRITABLE_HOOKS %CL%
  

This command sets the environment variable CL with the value -DDELAYIMP_INSECURE_WRITABLE_HOOKS, which helps resolve the issue.

Leave a comment