The specified `msvs_version` for node-gyp is not a recognized npm command

I'm currently in the process of building a Node application that can interact with C++ functions. I've come across suggestions to utilize the node-gyp package. Following the setup outlined in this guide, when attempting to execute npm config set msvs_version 2017 in my command prompt, it returns an error message.

npm ERR! msvs_version is not a recognized npm option

npm ERR! For more details, refer to:
npm ERR! C:\Users\user\AppData\Local\npm-cache_logs\2023-03-06T05_02_04_115Z-debug-0.log

I have Visual Studio 2022 and Python 3.10 installed on my system. I've experimented with different commands such as:

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

I've also attempted to reinstall the C++ development workloads within Visual Studio without success. Unfortunately, my searches on Google haven't yielded any helpful information. Any assistance would be greatly appreciated! Thank you 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 <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c1afb1ac81f8eff4eff1">[email protected]</a>
2 info using <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="deb0b1babb9ea8efe6f0efeaf0ec">[email protected]</a>
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

Answer №1

When attempting to utilize

npm config set msvs_version {version}
, it encountered an error for me.

Instead, I found success by using npm config edit and manually adding msvs_version={version} directly in the file.

I verified that npm recognized the change. You may want to try that approach.

Answer №2

To manually adjust npm Configuration: If changing the msvs_version using npm commands is not effective, you can edit the npm configuration file yourself. Simply run npm config edit in your terminal to open the configuration file in your default text editor. Once opened, insert the line msvs_version=2022 into the file and remember to save it

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Dealing with the "Module not found" issue when using node.js fork operation

Is there a way to handle errors from .fork() that involve non-existent files? var cp = require('child_process'); var fk = cp.fork("missing-file.js"); The error message displayed is: module.js:340 throw err; ^ Error: Cannot find modul ...

Building a Next.js website and deploying it to Elastic Beanstalk with AWS CodePipeline

I've successfully set up Codepipeline to: Retrieve source files from Github Build a functional Next.js website on Codebuild and deploy it to S3 Deploy the S3 file to Elastic Beanstalk using Codedeploy However, I'm encountering issues when Elast ...

React Native Electronic Gradebook (Agenda)

Currently working on a project to develop an electronic gradebook using React Native featuring a horizontal calendar, inspired by the features of react-native-calendar-strip. However, I am encountering difficulties when attempting to pass a specific date t ...

Express app not appearing in browser when using PM2

Utilizing PM2 within my Express application for process management and load balancing. Following the installation of PM2, I ran the command pm2 start bin/www which executed successfully in the command prompt, displaying the expected result: However, upon ...

Searching for JSON data using Express in Node.js

Applying the MEAN stack for developing search functionality with JSON data. The code snippet below showcases the connection to MongoDB and storing the retrieved data into an array. app.get('/all/', function(req, res) { var data = []; mongodb. ...

The Node.js Express framework automatically refreshes the server to update static resources whenever changes are detected

I have configured static resources using express import * as express from "express"; const app = express(); const port = 3000; app.use(express.static("./static")); app.listen(port, () => { console.log(`listening at http://localho ...

What is the process for implementing a new requirement for 'confirmed' users when they log in with passport.js?

Looking to enhance the functionality of passport.js by implementing a conditional check to verify if the user account is confirmed. The plan is to insert an 'if statement' towards the end of the code, right after validating the user's email ...

I am interested in utilizing this callback within a function that itself contains a callback

My goal is to retrieve a list of files by using the following code snippet: var templates; db.getTemplates(function(err, reply){ templates = reply; }); However, I am encountering an error in Node.js stating "undefined is not a function". Why is the c ...

Is there a way to efficiently clear the Express session for all users without the need to restart the application?

During my development of REST services using the nodejs express framework, I encountered an issue with storing user-specific data in sessions. I utilized the user's ID as a key to identify the user's data. The following code snippet demonstrates ...

Creating a dummy localhost server in Protractor to act as a substitute for a separate localhost server running on a distinct port

Test Scenario: In my testing scenario, I am trying to pass a token to my Chromium browser as a cookie. However, I am facing an issue where I cannot add it to the params because I need it to work with GET requests that are not localhost. When I make use o ...

Utilize npm libraries within the main directory of Sage 8.5.3 theme

When attempting to add npm libraries in the root of Sage 8.5.3, I encountered an error in the console stating that 'require' was not found. var GoogleMapsLoader = require('google-maps'); GoogleMapsLoader.load(function(goo ...

The functionality of Nuxt's asyncData is restricted when attempting to access data from authorized express routes

Setting up an online store. I began with the products, which can be pulled without authorization but require it for editing. The process is smooth so far, probably because it's happening on the client side where authentication information is included ...

The code "Grunt server" was not recognized as a valid command in the

I recently set up Grunt in my project directory with the following command: npm install grunt However, when I tried to run Grunt server in my project directory, it returned a "command not found" error. Raj$ grunt server -bash: grunt: command not found ...

When exporting a custom ES6 module and importing it into a different local project, you may encounter unexpected outputs such as being undefined or

Currently, I am using TypeScript 3.4.5 and Webpack 4.32.2 on Windows 10 via WSL. My goal is to create a local package of tools that consolidates basic classes into an index file for exporting. However, when I try to import these classes into other project ...

Simultaneously Accessing Data from MongoDB and MySQL

I have been working on retrieving data from my MongoDB database, which contains chat conversations. The retrieval process is successful and I am getting the desired output. However, in my MongoDB database, I only store userIDs, so I need to fetch additiona ...

While loop not yielding immediate result with asynchronous function

As a beginner in Node.js, I have successfully connected an LCD Panel and a 4x4 Membrane matrix keypad to my Raspberry Pi. Using Node.js, I have programmed them to work together. My goal is to have the LCD panel immediately display any key pressed on the ke ...

Is it beneficial to dockerize an AngularJS + nginx codebase?

Currently, I am working on an AngularJS front-end project that is hosted on nginx and communicates with a back-end Java server (which is not part of this codebase). Each time I need to install the package, I run the following commands: # ensure that node, ...

Struggling to create an API endpoint in express for handling database requests... receiving a 404 error code

I have a specific route set up in my application: app.post('/api/:type/*/*/*', apiRoute.api); Inside my route file, I've implemented the following logic: exports.api = function(req, res) { var type = req.params.type; var entity = ...

What are some alternative ways to link a local MongoDB database to my Android Studio application instead of using MongoLab?

Can someone please help me figure out how to connect my Android Studio project to a MongoDB database stored locally on my PC? I've been searching for solutions that don't involve using MLab, but I haven't had any luck. I've attempted f ...

What is the best way to bundle .scss files while releasing Storybook components in an npm package?

After successfully publishing my Storybook components in an npm package (let's call it my-storybook) and following the guidelines provided in this tutorial: I encountered an issue when trying to utilize them in a project. For each component exported ...