4

I'm currently trying to develop a Node application that can call C++ functions. I came across people saying that we have to use the node-gyp package. Upon following this setup, when I try to npm config set msvs_version 2017 in my cmd, it gives me the following error.

npm ERR! msvs_version is not a valid npm option

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Local\npm-cache_logs\2023-03-06T05_02_04_115Z-debug-0.log

I have Visual Studio 2022 installed and Python 3.10 installed. I've tried to use different commands such as:

npm config set msvs_version 2022 -g
npm config set msvs_version=2022

I've also tried to reinstall the C++ development workloads in Visual Studio but no luck with all of them. I can't seem to find any information on Google. Any help is appreciated! Thanks in advance.

Log file:

0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
1 info using npm@9.5.0
2 info using node@v18.14.2
3 timing npm:load:whichnode Completed in 2ms
4 timing config:load:defaults Completed in 2ms
5 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 2ms
6 timing config:load:builtin Completed in 2ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 1ms
9 timing config:load:project Completed in 2ms
10 timing config:load:file:C:\Users\user\.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:C:\Users\user\AppData\Roaming\npm\etc\npmrc Completed in 1ms
13 timing config:load:global Completed in 1ms
14 timing config:load:setEnvs Completed in 1ms
15 timing config:load Completed in 12ms
16 timing npm:load:configload Completed in 13ms
17 timing npm:load:mkdirpcache Completed in 1ms
18 timing npm:load:mkdirplogs Completed in 1ms
19 verbose title npm config set msvs_version 2017
20 verbose argv "config" "set" "msvs_version" "2017"
21 timing npm:load:setTitle Completed in 2ms
22 timing config:load:flatten Completed in 3ms
23 timing npm:load:display Completed in 4ms
24 verbose logfile logs-max:10 dir:C:\Users\user\AppData\Local\npm-cache\_logs\2023-03-06T05_02_04_115Z-
25 verbose logfile C:\Users\user\AppData\Local\npm-cache\_logs\2023-03-06T05_02_04_115Z-debug-0.log
26 timing npm:load:logFile Completed in 7ms
27 timing npm:load:timers Completed in 0ms
28 timing npm:load:configScope Completed in 0ms
29 timing npm:load Completed in 30ms
30 info config set "msvs_version" "2017"
31 timing command:config Completed in 2ms
32 verbose stack Error: `msvs_version` is not a valid npm option
32 verbose stack     at Config.set (C:\Program Files\nodejs\node_modules\npm\lib\commands\config.js:158:15)
32 verbose stack     at Config.exec (C:\Program Files\nodejs\node_modules\npm\lib\commands\config.js:120:22)
32 verbose stack     at Config.cmdExec (C:\Program Files\nodejs\node_modules\npm\lib\base-command.js:130:17)
32 verbose stack     at Npm.exec (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:154:20)
32 verbose stack     at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli.js:134:5)
33 verbose cwd C:\Users\user
34 verbose Windows_NT 10.0.22621
35 verbose node v18.14.2
36 verbose npm  v9.5.0
37 error `msvs_version` is not a valid npm option
38 verbose exit 1
39 timing npm Completed in 52ms
40 verbose code 1
41 error A complete log of this run can be found in:
41 error     C:\Users\user\AppData\Local\npm-cache\_logs\2023-03-06T05_02_04_115Z-debug-0.log
InvalidHop
  • 104
  • 1
  • 10
  • Since there are no answers added yet, I thought I might post what I did to keep working on my project. I simply ignored setting the msvs_version. At least, it still worked for me as of now. – InvalidHop Mar 17 '23 at 02:37
  • I also had this issue, I was wondering if you experienced any issue later, since `msvs_version` was not set to `2017` – Remix Protocol Mar 19 '23 at 10:28
  • @RemixProtocol as of now, I didn't encounter any errors or roadblocks yet. – InvalidHop Mar 20 '23 at 02:09

1 Answers1

0

Using npm config set msvs_version {version} errored for me as well.

However, using npm config edit then adding msvs_version={version} in the file directly worked fine.

I confirmed that it was picked up by npm. Give that a shot

djak250
  • 9
  • 3
  • I've just checked the node-gyp GitHub repo just now, and they've already amended the installation instruction with this commit https://github.com/nodejs/node-gyp/commit/c7927e228dfde059c93e08c26b54dd8026144583 – InvalidHop Apr 19 '23 at 01:53
  • I guess we don't have to run any more commands after installing Visual Studio Build Tools – InvalidHop Apr 19 '23 at 01:59