question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 vscode@1.1.37: 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 mkdirp@0.5.1: 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 node-gyp@8.3.0
npm ERR! gyp info using node@16.13.0 | 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 npm@8.1.3
npm info using node@v16.13.0
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

npm@8.1.3 C:\Users\heart\AppData\Roaming\npm\node_modules\npm
npm verb exit 0
npm timing npm Completed in 187ms
npm verb code 1

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:38 (15 by maintainers)

github_iconTop GitHub Comments

9reactions
walkerlalacommented, Jan 2, 2022

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.

8reactions
mrudulpcommented, Nov 20, 2021

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


gyp info it worked if it ends with ok
gyp info using node-gyp@8.4.0
gyp info using node@16.13.0 | 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
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I solve error gypgyp ERR!ERR! find VSfind VS ...
Reading through the log, the main error is due to this: msvs_version not set from command line or npm config. After this one...
Read more >
Npm install command failing with message "could not find ...
When I run the npm install command, npm starts downloading the ... ERR! find VS VCINSTALLDIR not set, not running in VS Command...
Read more >
VCINSTALLDIR not set, not running in VS Command Prompt
vcinstalldir not set, not running in vs command prompt. Add Answer | View In TPC Matrix. Technical Problem Cluster First Answered On November...
Read more >
python is not set from command line or npm - You.com | The AI ...
Reinstall Node.js. Run in terminal: npm uninstall node-sass. npm WARN using --force. npm i node-sass. npm rebuild node-sass --force.
Read more >
Manage Python environments and interpreters - Visual Studio ...
Use the Python Environments window to manage global, virtual, and conda environments. Install Python interpreters and packages and assign ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found