node-gyp icon indicating copy to clipboard operation
node-gyp copied to clipboard

how to fix `VS VCINSTALLDIR not set, not running in VS Command Prompt` using vs2022 ,help me please.

Open heartacker opened this issue 3 years ago • 50 comments

Please look thru your error log for the string gyp info using node-gyp@ and if the version number is less than the current release of node-gyp then please upgrade using the instructions at https://github.com/nodejs/node-gyp/blob/master/docs/Updating-npm-bundled-node-gyp.md and try your command again.

Requests for help with node-sass are very common. Please be aware that this package is deprecated, you should seek alternatives and avoid opening new issues about it here.

  • Node Version: 8.1.3
  • Platform: Windows
  • Compiler: VS2022 windows
  • Module:
$ npm install
npm WARN deprecated [email protected]: This package is deprecated in favor of @types/vscode and vscode-test. For more information please read: https://code.visualstudio.com/updates/v1_36#_splitting-vscode-package-into-typesvscode-and-vscodetest
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm ERR! code 1
npm ERR! path D:\heart\Git\MyVSCode\vs-shell-format\node_modules\keytar
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.7 found at "D:\Program Files\Python39\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version was set from command line or npm config
npm ERR! gyp ERR! find VS - looking for Visual Studio version 2022
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS unknown version "undefined" found at "D:\Program Files\Microsoft Visual Studio\2022\Community"
npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS valid versions for msvs_version:
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\heart\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
npm ERR! gyp ERR! stack     at C:\Users\heart\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16     
npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\heart\AppData\Roaming\npm\node_modules\npm\node_modules\nodnpm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! gyp ERR! System Windows_NT 10.0.22499
npm ERR! gyp ERR! command "D:\\Program Files\\nodejs\\node.exe" "C:\\Users\\heart\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd D:\heart\Git\MyVSCode\vs-shell-format\node_modules\keytar
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v8.3.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\heart\AppData\Local\npm-cache\_logs\2021-11-17T13_51_11_770Z-debug.log
$ npm --verbose
npm verb cli [
npm verb cli   'D:\\Program Files\\nodejs\\node.exe',
npm verb cli   'C:\\Users\\heart\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli   '--verbose'
npm verb cli ]
npm info using [email protected]
npm info using [email protected]
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 1ms
npm timing config:load:file:C:\Users\heart\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 2ms
npm timing config:load:builtin Completed in 2ms
npm timing config:load:cli Completed in 2ms
npm timing config:load:env Completed in 0ms
npm timing config:load:project Completed in 1ms
npm timing config:load:file:C:\Users\heart\.npmrc Completed in 0ms
npm timing config:load:user Completed in 0ms
npm timing config:load:file:C:\Users\heart\AppData\Roaming\npm\etc\npmrc Completed in 0ms
npm timing config:load:global Completed in 1ms
npm timing config:load:validate Completed in 1ms
npm timing config:load:credentials Completed in 0ms
npm timing config:load:setEnvs Completed in 1ms
npm timing config:load Completed in 9ms
npm timing npm:load:configload Completed in 9ms
npm timing npm:load:setTitle Completed in 0ms
npm timing npm:load:setupLog Completed in 1ms
npm timing config:load:flatten Completed in 1ms
npm timing npm:load:cleanupLog Completed in 2ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load:projectScope Completed in 0ms
npm timing npm:load Completed in 22ms
npm <command>

Usage:

npm install        install all the dependencies in your project
npm install <foo>  add the <foo> dependency to your project
npm test           run this project's tests
npm run <foo>      run the script named <foo>
npm <command> -h   quick help on <command>
npm -l             display usage info for all commands
npm help <term>    search for help on <term> (in a browser)
npm help npm       more involved overview (in a browser)

All commands:

    access, adduser, audit, bin, bugs, cache, ci, completion,
    config, dedupe, deprecate, diff, dist-tag, docs, doctor,
    edit, exec, explain, explore, find-dupes, fund, get, help,
    hook, init, install, install-ci-test, install-test, link,
    ll, login, logout, ls, org, outdated, owner, pack, ping,
    pkg, prefix, profile, prune, publish, rebuild, repo,
    restart, root, run-script, search, set, set-script,
    shrinkwrap, star, stars, start, stop, team, test, token,
    uninstall, unpublish, unstar, update, version, view, whoami

Specify configs in the ini-formatted file:
    C:\Users\heart\.npmrc
or on the command line via: npm <command> --key=value

More configuration info: npm help config
Configuration fields: npm help 7 config

[email protected] C:\Users\heart\AppData\Roaming\npm\node_modules\npm
npm verb exit 0
npm timing npm Completed in 187ms
npm verb code 1

heartacker avatar Nov 17 '21 14:11 heartacker

npm ERR! gyp info using [email protected]

Please upgrade to 8.4. https://github.com/nodejs/node-gyp/releases

cclauss avatar Nov 17 '21 16:11 cclauss

$ node-gyp --list    

  Usage: node-gyp <command> [options]

  where <command> is one of:
    - build - Invokes `msbuild` and builds the module
    - clean - Removes any generated build files and the "out" dir
    - configure - Generates MSVC project files for the current module
    - rebuild - Runs "clean", "configure" and "build" all at once
    - install - Install node development files for the specified node version.
    - list - Prints a listing of the currently installed node development files
    - remove - Removes the node development files for the specified version

[email protected]  C:\Users\heart\AppData\Roaming\npm\node_modules\node-gyp
[email protected]

seem that I had updated node-gyp to 8.4.0. but when I exec eval npm install they are still using v8.3.0

image

heartacker avatar Nov 17 '21 22:11 heartacker

https://github.com/nodejs/node-gyp/blob/master/docs/Updating-npm-bundled-node-gyp.md

cclauss avatar Nov 19 '21 10:11 cclauss

I have VS 2022 and node-gyp8.4 I still see error


gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.9.5 found at "C:\ProgramData\Miniconda3\python.exe"
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
.....
\\bin\\node-gyp.js" "configure"

gyp ERR! node -v v16.13.0
gyp ERR! node-gyp -v v8.4.0
gyp ERR! not ok

mrudulp avatar Nov 20 '21 19:11 mrudulp

https://github.com/nodejs/node-gyp/blob/master/docs/Updating-npm-bundled-node-gyp.md

@mrudulp Follow the Guide. Is it fixed。

heartacker avatar Nov 20 '21 23:11 heartacker

@heartacker The log output above says:

gyp info using [email protected]

which is the current release so no further upgrade is needed.

Is there a VCINSTALLDIR value printed when you run the SET command (without parameters) at Visual Studio command prompt?

cclauss avatar Nov 21 '21 05:11 cclauss

@heartacker yes, have followed those instructions before posting.

VCIDEInstallDir=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\VC\
VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\
VCToolsInstallDir=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\
VCToolsRedistDir=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.30.30704\
VCToolsVersion=14.30.30705
VisualStudioDir=C:\Users\<user>\Documents\Visual Studio 2022
VisualStudioEdition=Microsoft Visual Studio Community 2022
VisualStudioVersion=17.0
VS170COMNTOOLS=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\
VSAPPIDDIR=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\
VSAPPIDNAME=devenv.exe
VSCMD_ARG_app_plat=Desktop
VSCMD_ARG_HOST_ARCH=x86
VSCMD_ARG_TGT_ARCH=x86
VSCMD_VER=17.0.1
VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2022\Community\
VSLANG=1033
VSSDK150INSTALL=C:\Program Files\Microsoft Visual Studio\2022\Community\VSSDK
VSSDKINSTALL=C:\Program Files\Microsoft Visual Studio\2022\Community\VSSDK
VSSKUEDITION=Community

@cclauss yes but in the Visual Studio Developer Command prompt only. Not on regular cmd

mrudulp avatar Nov 21 '21 17:11 mrudulp

Cool. In cmd, type SET VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\ like they do in https://stackoverflow.com/questions/1679560/using-visual-studio-command-prompt-tools-everywhere

cclauss avatar Nov 21 '21 17:11 cclauss

Nope did not help or did something wrong... here is what I did

@SET VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\
@SET VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2022\Community\
@SET VCIDEInstallDir=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\VC\
@SET VCToolsInstallDir=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\
@SET VCToolsRedistDir=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.30.30704\
@SET VCToolsVersion=14.30.30705
@SET VisualStudioEdition=Microsoft Visual Studio Community 2022
@SET VisualStudioVersion=17.0
@SET VS170COMNTOOLS=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\
@SET VSCMD_VER=17.0.1
@SET VSLANG=1033
@SET VSSDK150INSTALL=C:\Program Files\Microsoft Visual Studio\2022\Community\VSSDK
@SET VSSDKINSTALL=C:\Program Files\Microsoft Visual Studio\2022\Community\VSSDK
@SET VSSKUEDITION=Community
@if "%VSINSTALLDIR%"=="" goto error_no_VSINSTALLDIR
@if "%VCINSTALLDIR%"=="" goto error_no_VCINSTALLDIR


@goto end

:error_no_VSINSTALLDIR
@echo ERROR: VSINSTALLDIR variable is not set. 
@goto end

:error_no_VCINSTALLDIR
@echo ERROR: VCINSTALLDIR variable is not set. 
@goto end

:end

and this is the partial output for node-gyp configure

gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS running in VS Command Prompt, installation path is:
gyp ERR! find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
gyp ERR! find VS - will only use this version
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found

mrudulp avatar Nov 21 '21 19:11 mrudulp

https://github.com/nodejs/node-gyp/tree/master/docs

cclauss avatar Dec 05 '21 08:12 cclauss

@mrudulp I'm the same as you, have you solved it?

kefeibuhuifei avatar Dec 27 '21 09:12 kefeibuhuifei

In cmd, did you do npm config set msvs_version 2022 ?

cclauss avatar Dec 27 '21 14:12 cclauss

i do npm config set msvs_version 2019, i use Visual Studio Build Tools lasted is 2019,but i can not work https://github.com/nodejs/node-gyp/issues/2581

kefeibuhuifei avatar Dec 28 '21 02:12 kefeibuhuifei

Probably because of the "constrained language mode" of powershell.

node-gyp use a piece of c# code to obtained the information of visual studio:

image

On my machine, the corresponding javascript file is C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js, which invokes C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\Find-VisualStudio.cs;

However, PowerShell has a "ConstrainedLanguage" mode which prevent evaluation of c# code. See: ConstrainedLanguag, and node-gyp does not print useful information about this...

To workaroud this, try to set the system __PSLockdownPolicy environment variable to 8 and re-launch your cmd or powershell.

walkerlala avatar Jan 02 '22 09:01 walkerlala

Is there a way to fix this in code that does not require rebooting the shell with a nonstandard config?

cclauss avatar Jan 02 '22 14:01 cclauss

I have the same error , i have node v 17.1.0 , node-gyp v 8.4.1 ans VS 2022 .

image image

Ziakimbogo avatar Jan 09 '22 10:01 Ziakimbogo

Same error. Node 16.13.1 node-gyp 8.4.0

UPDATE

I followed the instructions from here and everything works now. Thanks a ton, @heartacker. I've spent days on this.

thierryntoh24 avatar Jan 19 '22 03:01 thierryntoh24

Can this issue be closed?

cclauss avatar Jan 19 '22 14:01 cclauss

Yes.

thierryntoh24 avatar Jan 19 '22 14:01 thierryntoh24

@thierryntoh24 not sure how its working for you guys. I did the fix in the node.exe folder on windows, I still face same issue. @cclauss

 ajink@LAPTOP-018O850F C:\Projects\work\pret\auth-api git:main ❯❯❯ npm i heapdump --save-dev
npm ERR! code 1
npm ERR! path C:\Projects\work\pret\auth-api\node_modules\heapdump
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! {
npm ERR!   ps: 'C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe',
npm ERR!   csFile: 'C:\\Projects\\work\\pret\\auth-api\\node_modules\\node-gyp\\lib\\Find-VisualStudio.cs',
npm ERR!   psArgs: [
npm ERR!     '-ExecutionPolicy',
npm ERR!     'Unrestricted',
npm ERR!     '-NoProfile',
npm ERR!     '-Command',
npm ERR!     "&{Add-Type -Path 'C:\\Projects\\work\\pret\\auth-api\\node_modules\\node-gyp\\lib\\Find-VisualStudio.cs';[VisualStudioConfiguration.Main]::PrintJson()}"
npm ERR!   ]
npm ERR! }
npm ERR! { info: null }
npm ERR! AJINKYA
npm ERR! {
npm ERR!   msvs: '2022',
npm ERR!   dir: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022'
npm ERR! }
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.10.0 found at "C:\Python310\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version was set from command line or npm config
npm ERR! gyp ERR! find VS - looking for Visual Studio version 2022
npm ERR! gyp ERR! find VS running in VS Command Prompt, installation path is:
npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022"
npm ERR! gyp ERR! find VS - will only use this version
npm ERR! gyp ERR! find VS checking VS2022 (17.0.32112.339) found at:
npm ERR! gyp ERR! find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features"
npm ERR! gyp ERR! find VS - found VC++ toolset: v143
npm ERR! gyp ERR! find VS - found Windows SDK: 10.0.19041.0
npm ERR! gyp ERR! find VS - does not match this Visual Studio Command Prompt
npm ERR! gyp ERR! find VS checking VS2017 (15.9.28307.1778) found at:
npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features"
npm ERR! gyp ERR! find VS - found VC++ toolset: v141
npm ERR! gyp ERR! find VS - found Windows SDK: 10.0.17763.0
npm ERR! gyp ERR! find VS - msvs_version does not match this version
npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS msvs_version does not match this VS Command Prompt or the
npm ERR! gyp ERR! find VS installation cannot be used.
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack     at VisualStudioFinder.fail (C:\Projects\work\pret\auth-api\node_modules\node-gyp\lib\find-visualstudio.js:129:47)
npm ERR! gyp ERR! stack     at C:\Projects\work\pret\auth-api\node_modules\node-gyp\lib\find-visualstudio.js:78:16
npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Projects\work\pret\auth-api\node_modules\node-gyp\lib\find-visualstudio.js:375:14)
npm ERR! gyp ERR! stack     at C:\Projects\work\pret\auth-api\node_modules\node-gyp\lib\find-visualstudio.js:74:14
npm ERR! gyp ERR! stack     at C:\Projects\work\pret\auth-api\node_modules\node-gyp\lib\find-visualstudio.js:396:16
npm ERR! gyp ERR! stack     at C:\Projects\work\pret\auth-api\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack     at C:\Projects\work\pret\auth-api\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:404:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! gyp ERR! System Windows_NT 10.0.19044
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Projects\\work\\pret\\auth-api\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Projects\work\pret\auth-api\node_modules\heapdump
npm ERR! gyp ERR! node -v v16.10.0
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ajink\AppData\Local\npm-cache\_logs\2022-01-21T09_33_14_122Z-debug.log

steelx avatar Jan 21 '22 09:01 steelx

@steelx , I made an installation guide here. Follow it and lemme know. You might wanna uninstall the TFJS first. Also, don’t forget to add the C++ pack to your VS

thierryntoh24 avatar Jan 21 '22 11:01 thierryntoh24

@steelx try uninstalling your Node and start back afresh.

thierryntoh24 avatar Jan 21 '22 11:01 thierryntoh24

Hi, I'm facing this issue from last 4days, I have tried all the methods, still facing same issue. Can anyone please help me. node 16.15.0 npm 8.5.5

npm config list ; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc

prefix = "C:\Users\manju\AppData\Roaming\npm"

; "global" config from C:\Users\manju\AppData\Roaming\npm\etc\npmrc

; msvs_version = "2017" ; overridden by user

; "user" config from C:\Users\manju.npmrc

and = "yarn" config = "msvs_version" msbuild_path = "C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\MSBuild.exe" msvs_version = "2017" node_gyp = "C:\Users\manju\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" python = "c:\Python\27\python.exe" python3.10 = "" registry = "https://registry.npmjs.org/"

; node bin location = C:\Program Files\nodejs\node.exe ; cwd = E:\web development\skuad\talent-view-service ; HOME = C:\Users\manju ; Run npm config ls -l to show all defaults.

npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using [email protected] npm ERR! gyp info using [email protected] | win32 | x64 npm ERR! gyp info find Python using Python version 3.10.4 found at "C:\Users\manju\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe" npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config npm ERR! gyp ERR! find VS running in VS Command Prompt, installation path is: npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022" npm ERR! gyp ERR! find VS - will only use this version npm ERR! gyp ERR! find VS checking VS2017 (15.9.28307.1974) found at: npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features" npm ERR! gyp ERR! find VS - found VC++ toolset: v141 npm ERR! gyp ERR! find VS - found Windows SDK: 10.0.17763.0 npm ERR! gyp ERR! find VS - does not match this Visual Studio Command Prompt npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use npm ERR! gyp ERR! find VS looking for Visual Studio 2015 npm ERR! gyp ERR! find VS - not found npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8 npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload. npm ERR! gyp ERR! find VS For more information consult the documentation at: npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS npm ERR! gyp ERR! configure error npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use npm ERR! gyp ERR! stack at VisualStudioFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47) npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16 npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:363:14)
npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14 npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:384:16 npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7 npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16 npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:406:5) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28) npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1092:16) npm ERR! gyp ERR! System Windows_NT 10.0.19043 npm ERR! 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"
npm ERR! gyp ERR! cwd E:\web development\skuad\talent-view-service\node_modules\node-rdkafka npm ERR! gyp ERR! node -v v16.15.0 npm ERR! gyp ERR! node-gyp -v v9.0.0 npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\manju\AppData\Local\npm-cache_logs\2022-05-27T04_18_21_305Z-debug-0.log

if i run node-gyp configure --msvs_version=2017 I'll get same error with this line change msvs_version was set from command line or npm config

please anyone help me

manjumallesh678 avatar May 27 '22 04:05 manjumallesh678

msvs_version = "2017" node_gyp = "C:\Users\manju\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" python = "c:\Python\27\python.exe"

npm config set msvs_version 2022

Python 3.10.4 is found correctly despite the out-of-date pythonsetting.

@nodejs/platform-windows I really dislike the following logic flow:

npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022"
npm ERR! gyp ERR! find VS - will only use this version
npm ERR! gyp ERR! find VS checking VS2017 (15.9.28307.1974) found at:

This seems to be a recurring blocker among our Window issues.

cclauss avatar May 27 '22 06:05 cclauss

Hi @cclauss , Thank you so much for responding,

How to fix this issue now

manjumallesh678 avatar May 27 '22 06:05 manjumallesh678

Try running npm config set msvs_version 2022 before your other commands.

cclauss avatar May 27 '22 06:05 cclauss

Hi @cclauss , I tried this before running npm install, getting same error

In my machine i only have 2017 build tools, should i install manually

I have installed windows build tools using npm install --global --production windows-build-tools

npm config list ; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc

prefix = "C:\Users\manju\AppData\Roaming\npm"

; "global" config from C:\Users\manju\AppData\Roaming\npm\etc\npmrc

; msvs_version = "2017" ; overridden by user

; "user" config from C:\Users\manju.npmrc

and = "yarn" config = "msvs_version" msbuild_path = "C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\MSBuild.exe" msvs_version = "2022" node_gyp = "C:\Users\manju\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js"
python = "c:\Python\27\python.exe" python3.10 = "" registry = "https://registry.npmjs.org/"

; node bin location = C:\Program Files\nodejs\node.exe ; cwd = E:\web development\skuad\talent-view-service ; HOME = C:\Users\manju ; Run npm config ls -l to show all defaults.

npm ERR! code 1 npm ERR! path E:\web development\skuad\talent-view-service\node_modules\node-rdkafka npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using [email protected] npm ERR! gyp info using [email protected] | win32 | x64 npm ERR! gyp info find Python using Python version 3.10.4 found at "C:\Users\manju\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe" npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config npm ERR! gyp ERR! find VS running in VS Command Prompt, installation path is: npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022" npm ERR! gyp ERR! find VS - will only use this version npm ERR! gyp ERR! find VS checking VS2017 (15.9.28307.1974) found at: npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features" npm ERR! gyp ERR! find VS - found VC++ toolset: v141 npm ERR! gyp ERR! find VS - found Windows SDK: 10.0.17763.0 npm ERR! gyp ERR! find VS - does not match this Visual Studio Command Prompt npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use npm ERR! gyp ERR! find VS looking for Visual Studio 2015 npm ERR! gyp ERR! find VS - not found npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8 npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload. npm ERR! gyp ERR! find VS For more information consult the documentation at: npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS npm ERR! gyp ERR! configure error npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use npm ERR! gyp ERR! stack at VisualStudioFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47) npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16 npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:363:14) npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14 npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:384:16 npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7 npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16 npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:406:5) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28) npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1092:16) npm ERR! gyp ERR! System Windows_NT 10.0.19043 npm ERR! 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" npm ERR! gyp ERR! cwd E:\web development\skuad\talent-view-service\node_modules\node-rdkafka
npm ERR! gyp ERR! node -v v16.15.0 npm ERR! gyp ERR! node-gyp -v v9.0.0 npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\manju\AppData\Local\npm-cache_logs\2022-05-27T06_10_39_299Z-debug-0.log

manjumallesh678 avatar May 27 '22 06:05 manjumallesh678

In my machine i only have 2017 build tools

Oh. Then try running npm config set msvs_version 2017 before your other commands.

We want both msbuild_path AND msvs_version to point to 2017 artifacts.

cclauss avatar May 27 '22 06:05 cclauss

HI @cclauss, Can you verify

; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc

prefix = "C:\Users\manju\AppData\Roaming\npm"

; "global" config from C:\Users\manju\AppData\Roaming\npm\etc\npmrc

; msvs_version = "2017" ; overridden by user

; "user" config from C:\Users\manju.npmrc

and = "yarn" C:\Program Files\Microsoft Visual Studio\2017\Community\Msbuild\Current\Bin\MSBuild.exe = "" config = "msvs_version" Files\Microsoft = "Visual" msbuild_path = "C:\Program Files\Microsoft Visual Studio\2017\Community\Msbuild\Current\Bin\MSBuild.exe" msvs_version = "2017" node_gyp = "C:\Users\manju\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" python = "c:\Python\27\python.exe" python3.10 = "" registry = "https://registry.npmjs.org/" Studio\2017\Community\Msbuild\Current\Bin\MSBuild.exe = ""

; node bin location = C:\Program Files\nodejs\node.exe ; cwd = C:\WINDOWS\system32 ; HOME = C:\Users\manju ; Run npm config ls -l to show all defaults.

manjumallesh678 avatar May 27 '22 06:05 manjumallesh678

The line C:\Program Files\Microsoft Visual Studio\2017\Community\Msbuild\Current\Bin\MSBuild.exe = "" looks a bit strange to me but I think you are good to go.

cclauss avatar May 27 '22 06:05 cclauss

Hi @cclauss , Do you know how to remove it from npm config

manjumallesh678 avatar May 27 '22 06:05 manjumallesh678

Hi @cclauss , getting same error

npm ERR! gyp info using [email protected] npm ERR! gyp info using [email protected] | win32 | x64 npm ERR! gyp info find Python using Python version 3.10.4 found at "C:\Users\manju\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe" npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config npm ERR! gyp ERR! find VS running in VS Command Prompt, installation path is: npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022" npm ERR! gyp ERR! find VS - will only use this version npm ERR! gyp ERR! find VS checking VS2017 (15.9.28307.1974) found at: npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features" npm ERR! gyp ERR! find VS - found VC++ toolset: v141 npm ERR! gyp ERR! find VS - found Windows SDK: 10.0.17763.0 npm ERR! gyp ERR! find VS - does not match this Visual Studio Command Prompt npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use npm ERR! gyp ERR! find VS looking for Visual Studio 2015 npm ERR! gyp ERR! find VS - not found npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8 npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload. npm ERR! gyp ERR! find VS For more information consult the documentation at: npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS npm ERR! gyp ERR! configure error npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use npm ERR! gyp ERR! stack at VisualStudioFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47) npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16 npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:363:14) npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14 npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:384:16 npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7 npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16 npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:406:5) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28) npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1092:16) npm ERR! gyp ERR! System Windows_NT 10.0.19043 npm ERR! 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" npm ERR! gyp ERR! cwd E:\web development\skuad\talent-view-service\node_modules\node-rdkafka
npm ERR! gyp ERR! node -v v16.15.0 npm ERR! gyp ERR! node-gyp -v v9.0.0 npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\manju\AppData\Local\npm-cache_logs\2022-05-27T07_01_18_568Z-debug-0.log

manjumallesh678 avatar May 27 '22 07:05 manjumallesh678

npm ERR! gyp ERR! find VS running in VS Command Prompt, installation path is: npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022"

Are you in a VS2022 command prompt instead of a VS2017 command prompt? If so, is there a way to switch?

I guess you should install the 2022 build tools and go all-in on 2022 instead of 2017.

cclauss avatar May 27 '22 07:05 cclauss

Maybe your Powershell is in ConstrainedLanguage mode. node-gyp will fail to find Visual Studio in this mode. Check this in Powershell: $ExecutionContext.SessionState.LanguageMode.

You can see this how to change PowerShell mode to fulllanguage mode from constrained mode?

Masson avatar Jun 28 '22 06:06 Masson