NPM error (System.ComponentModel.Win32Exception) in Visual Studio 2015 - node.js

I need to get started coding an Angular 2 application at my workplace but I get the following error in VS:
====Executing command 'npm install'====
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at Microsoft.VisualStudioTools.Project.ProcessOutput..ctor(Process process, Redirector redirector)
Error executing npm - unable to start the npm process
Error - Cannot load global packages.
I've followed Angular 2 VS 2015 QuickStart guide, located here:
https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html
Prerequisites are all installed:
VS 2015 with Update 3
nodeJS v.6.9.1
TypeScript v.2.0.6.0
This error shows up in the output when I open the project or try to do a 'restore packages'
Thanks.

It looks like you need other version of Node. You have maybe too new version of Node I guess. According to this thread: https://github.com/Microsoft/nodejstools/issues/476
you should downgrade and configure VS:
It looks like vs2015 does not work with the latest 5.0.0 Node. Replacing with 4.2.2 one solves this issue for me. To make Visual Stuido use the same Node and npm as cmd by changing some files including node.exe under following folder:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External
Look for this article also http://jameschambers.com/2015/09/upgrading-npm-in-visual-studio-2015/

I finally found out the reason.. nodeJS was installed with the x86 installer on a x64 computer. Installed nodeJS in 64 bit and it resolved my issue.
Hope this help anyone who has this error.

Related

Must I install NodeJS when it is already installed by the Visual Studio Installer?

Info
I am using Visual Studio 2019.
The Microsoft guides for creating SPA's requires you to install NodeJS from the official website, at least the guides I have perused so far.
When I installed Visual Studio I selected NodeJS development.
Visual studio installed NodeJS here: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\NodeJs
Question
My goal is to use NodeJS for development and NOT interfere with the operation of Visual Studio AND to only have one version of NodeJS installed AND to avoid installing NVM.
Must I install NodeJS again or should I use the version installed by Visual Studio?
It also raises the following concerns, which I don't expect to get answered here, but it would be nice to know:
If I install it again, will conflicts occur between the two versions?
If conflicts occur, how do I resolve them?
If I use the one installed by Visual Studio, can I update it at will, or does Visual Studio require a specific version of NodeJS?
See also
Multiple versions of node on windows
Install different versions of NodeJS
There was a question posted to the Microsoft Developer Community forums that also addresses this question. Quote:
Thank you for reporting this feedback. The NodeJS workload doesn’t install the Node Runtime and NPM on it’s own. The install you mentioned in the Visual Studio folder is used internally for Visual Studio operations. You would need to install the runtime you want to use separately, which would be picked up by NodeJS workload and corresponding apps.
In response to your question:
Must I install NodeJS again or should I use the version installed by Visual Studio?
Yes - so while it seems a whole separate copy of Node.js and npm is installed under C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\NodeJs when you install Visual Studio (with the Node.js workload), you are meant to install the regular version of Node.js and npm from https://nodejs.org/ and use that in your day-to-day development activities, which is what I've been doing (except with VS2022) and have not encountered any conflicts so far.
Edit: IF you do encounter conflicts with installed Node.js or npm versions, there is a way to resolve them, by changing the order of precedance of paths that VS uses. Go to 'Tools -> Options -> CTRL+E: "External Web Tools"' and you should see this:
Move the $(PATH) entry up or down depending on which version should take priority.
You can check if NodeJS is installed or not using the node -v and check if npm package manager is installed using npm -v. If you find that NodeJS is not installed, then download the NodeJS from here.

NPM missing in visual studio 2017

I have Visual Studio 2017 and added support for Node.JS Development and ASP.Net Core. But when I go to Package Manager Console and write
npm
I am getting following error
The term 'npm' is not recognized as the name of a cmdlet
What could be a problem?
NPM should be fully integrated with VS
https://webtooling.visualstudio.com/package-managers/npm/
The default path for npm is:
C:\%ProgramFiles%\nodejs
You should have a npm.cmd there. The Windows PATH environment variable needs to point to that folder.
My advice is to reinstall nodejs from the source:
https://nodejs.org/en/download/
During Setup, making sure you choose Custom Setup and select "Add to PATH" and make sure it is set to "Will be installed on local hard drive".
(Of course, shut down all Visual Studio instances before doing the above.)

Visual Studio Installer is not installing node.js

In Visual Studio Installer, I selected the Node.js development option. It runs successfully. But, if I try to run cmd node -v. It tells me node does not exist.
I tried a few other things including uninstalling and reinstalling the Node.js development option in VS Installer. Plus installing the latest version of node from the website.
However, when I try to run the pre-packed Angular solution that comes with VS 2017 I have issues. The solution will not even start.
The best I have been able to do is install Node 6.10.3. Once I do that, the web site comes up. But, I get a JavaScript error in the vendor.js file. I am able to continue but I get this error when I try navigate to another menu item. Plus the Hot Module Replacement does not seem to be working. (It does not automatically recompile my TypeScript file if I made a change).
I think the key is getting the Node.js development option installed correctly since I am able to run the pre-packed Angular solution on another PC and the Hot Module Replacement works fine.
Please let me know if anyone has any ideas on how to resolve.
I had a similar, if not the same, issue. Check the Visual Studio installation directory (2017 Professional in this case) for Node:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\NodeJs
If the executable is there, add the directory to your PATH.

Node Sass No Binding for Your current environment

I've seen quite a few of these questions on SO, but none seem to solve or match the problem.
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 6.x. The odd thing is, I don't have Node.js 6.x installed. From the command line, node -v gives me v5.10.1.
I'm the Angular4 Universal Asp.net core visual studio 2017 template straight out of the box.
I've tried
npm rebuild node-sass --force
Reordering node in Web External toolsin Visual Studio
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HL4JSD9SSV8E": An unhandled exception was thrown by the application.
System.Exception: Call to Node module failed with error: Prerendering failed because of error: Error: Module build failed: Error: Missing binding D:\Projects\angular2\node_modules\node-sass\vendor\win32-x64-48\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 6.x
Found bindings for the following environments:
Windows 64-bit with Node.js 5.x
This usually happens because your environment has changed since running npm install.
Run npm rebuild node-sass --force to build the binding for your current environment.
at module.exports (D:\Projects\angular2\node_modules\node-sass\lib\binding.js:15:13)
at Object. (D:\Projects\angular2\node_modules\node-sass\lib\index.js:14:35)
Where have I gone wrong?
On Visual Studio 2017 (15.4.1) you should go to:
Tools > Configure External Tools > Projects and Solutions > Web Package Management > External Web Tools
Then reorder the tools as seen below.
This worked for me.
Deleting node_modules folder and re-installing npm modules using npm install worked for me.
Visual Studio ships it's own version of Node embedded so that's why you see a mismatch.
The TROUBLSHOOTING guide in the repo covers how to work around this https://github.com/sass/node-sass/blob/master/TROUBLESHOOTING.md#using-node-sass-with-visual-studio-2015-task-runner

Getting Build Error for Cordova plugin integration on Visual Studio 2015 TACo

This is regarding Cordova based universal app development using Visual Studio 2015 - Tools for Apache Cordova (TACo).
Here is the sample code which I am trying to run: AngularJSToDo app. In this app, there is GeoLocation Cordova plugin is being used. In config.xml:
<vs:plugin name="org.apache.cordova.geolocation" version="0.3.10" />
While building application for Windows Phone Emulator 8.1, it throws an error after below process:
------ Adding plugin: cordova-plugin-geolocation#2.2.0
1> Calling plugman.fetch on plugin "cordova-plugin-geolocation#2.2.0"
1> Fetching plugin "cordova-plugin-geolocation#2.2.0" via plugin registry
1>MDAVSCLI : error : read ECONNRESET
This error appears after a long time fetching event. I have already tried installing particular plugin using "npm" command through command prompt, but VS build automatically clears older plugins and re-download and install latest ones.
In error section, it says
"read ECONNRESET"
Please guide me what should be done to resolve this error from Visual Studio build.
Reference: https://taco.visualstudio.com/en-us/docs/create-a-hosted-app/
Your plugin add is failing because Cordova has closed the Plugin registry and moved to npm. That means all Cordova versions less than 5.x which don't use npm will no longer be able to add plugins.
If you are not on the latest version of TACO, update to make sure that you are on a version that can add a plugin from npm
Then, instructions after updating:
Go to config.xml -> plugins
remove the camera plugin
Add it back in again from the core plugin list
Actually I just ran the sample myself, and had no problem getting it to load on the iOS simulator, but it pulled the plugin from npm and not the plugin registry.
This issue had been resolved by restarting node(npm) server. Below are the steps what I did.
Terminal - Ctrl+C to stop the npm server
Go to particular project folder, and add the plugins using below command
cordova plugin add <plugin-name>
Restart the node server: remotebuild
Hope this helps to others.

Resources