Does anyone know of a sanctioned way to update Node within Visual Studio 2017? I've got Node 6 set up on my development PC but VS2017 appears to come with a bundled copy of Node 5, which means that running npm install on my command line sets up various packages like node-sass with bindings for Node 6, so when I then run gulp tasks from the VS Task Runner things fall over due to the mismatched versions.
I found the VS Node install at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External but I'm a little reluctant to just hack about and replace it. Anyone got any experience of upgrading this? I know I can sync by downgrading the version on my PC but that seems backwards.
Go to:
Tools > Options > Projects and Solutions > Web Package Management > External Web Tools
Then you need to add your Node install directory to the top of the list, like so:
You don't need to add a new Node install directory, Node exists in PATH.
Notice how $(PATH) is below the internal path $(DevEnvDir)\Extensions\Microsoft\Web Tools\External.
To use the global PATH environment variable before the internal path, you can just use the arrows at the top-right to change the order.
This is what it looks like when the global PATH is searched before the internal one and therefore will make Visual Studio use your own versions of the tools.
For me, the issue turned out to be that there was a local node.exe file in the same directory that the csproj file was in, along with a node.exe.config file.
I had a post-build event that would call gulp to do some other work and VS2017 would use the local node.exe file rather than what was listed in my $(PATH) variable. This was an earlier version of node that I didn't want to use, so the solution for me was to either remove the local node.exe so the one listed in $(PATH) would be used or upgrade the local node.exe file if the node.exe.config is really needed.
I just wanted to add this here in case someone else runs into this same issue.
It looks as if options in
Tools > Options > Projects and Solutions > Web Package Management > External Web Tools
have no effect. However it is possible to set the Node version through
Project > Properties
Related
Using Visual Studio 2019, I have downloaded all the dependencies needed to run NodeJS scripts and all works well. I can only run each .js script from VS (Ctrl+F5), but I want to know whether its possible to run a series of scripts like I would normally do via command prompt using npm start, but in real-time through VS? It's very important to me that I do not modify any script file in order to make this work, but rather let VS do the job instead of npm start, if It's possible at all.
I already have a project setup which I can successfully run via command prompt with npm start, but can I run and debug it with VS?
My main goal is to get any console output and even use breakpoints, aka. properly debug my code.
Actually, in VS IDE, there is a default node js project template that Microsoft provided.
You only have to install the workload Node.js development on the vs_installer so that you can use that template.
I think you should create such project template which follows the rule of VS IDE with node.js. And then migrate your old project's content into this new project.
Note: in this project, there is no such easy way to start several js files at the same time unless you nest nested js methods in the starting js file. And other types of projects do the same.
If you want to debug other js files, you only need to right-click on the file on the Solution Explorer. Every time switch like this, you can debug other js files.
You do not have to use npm start in this way and just click Debug to debug the project.
I am not sure about Visual studio, but you can debug on Visual Studio Code.
you can debug from run menu.
I'm building a .Net Core application using Angular for my client-side code. For the most part, I'm using the default template that is included in VS 2017. For whatever reason, VS is making my node_modules folder read only. Before I was able to install packages via command line in the directory that holds my client side code as well as my package.json file and my node_modules folder. Before I was able to do this, but now it is defaulting the folder to read only which is invaliding all of my npm commands. I've verified that this is the case because I can remove the read only attribute via windows explorer and then run any of my commands like npm install.
Has anyone else encountered this before? If so, what did you do to resolve this?
Thanks!
Okay, I found the answer. VS puts a lock on the node_modules folder while it is running.
So, I guess for now if you need to add packages just close VS first.
I'm developing a front-end package and this is my environment:
IDE: Visual Studio (I'm on Windows and we use TypeScript)
Package manager: NPM
Task runner: Gulp
CI: TeamCity
My problem is that I'm trying to avoid installing node and Gulp globally on my build servers (mainly because I don't want to bother managing this - installing, updating, synchronizing, etc.).
So I found a NuGet package (https://www.nuget.org/packages/Npm.js/) which allowed me to restore all the packages without having node installed on the machine. But then the problem was that the local Gulp I installed assumes there's a node.exe right next to it or in the machine's path:
#IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\gulp\bin\gulp.js" %*
) ELSE (
#SETLOCAL
#SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\gulp\bin\gulp.js" %*
)
Now obviously this won't work since I don't have node installed on the build machine and there's no local node installation inside node_modules.
So is there any way to avoid installing my build tools globally on each build server? Or were Node and Gulp intended to be installed everywhere? How should then updates be maintained? It's not like a Visual Studio release which comes out once every few months... Or do you just ignore frequent releases of the build tools?
I could also add the NuGet package to the path but that (the path where node.exe is located) depends on the version of the NuGet package and requires more maintenance whenever updating it. So I prefer not going this way either...
It's not optimal but here's what I ended up doing: I used a NuGet package for setting environment variables in MSBuild and created the following build configuration:
<Target Name="GulpBuild">
<SetEnvVariable Name="path" Value="%path%;..\packages\Node.js.5.3.0" />
<Exec Command="node_modules/.bin/gulp" />
</Target>
Now when I build the solution in VS (CTRL+Shift+B) it adds the node location to the path and then calls gulp. Of course I guess I could have just written the gulp command myself including the node path.
In any case, this is of course not optimal because I need to manually update the location if I update the Node.js version, but I couldn't find any better solution.
At least the path configuration is defined inside the repository and does not depend on any machine configuration.
Late here, but I think you can setup your gulp project to run with the gulp installed to node_modules. For example, on npm start you can use the path the binary.
In short, can you change the project to not use the global gulp? It might be work looking int.
I am doing a clean install of Windows 10 Professional (x64) and am noticing some peculiar files appearing in the root of my home directory, specifically I see...
.v8flags.3.14.5.9.Ciel
Ciel is obviously my username; I've tried to do a search on this file and found very little - the best I can tell is that it relates to nodejs, which might make sense because I have Visual Studio 2015 installed.
Can anyone else identify what this file is, and if I need to keep it?
You can safely delete it.
The file is used by the nodejs module v8flags for caching. If you delete it it will create a new one on next run.
I guess it was created because Gulp depends on v8flags and:
The ASP.NET 5 templates included in Visual Studio 2015 use Gulp, and they install Gulp into your project’s node_components folder so it’s all ready for you to use in your project.
https://msdn.microsoft.com/en-us/magazine/mt595751.aspx
Update: The new name of the file is .v8flags.{version}.{md5-hash-of-username}.json.
I've inherited a MEANJS project that I've successfully managed to open in Visual Studio 2015 via the "Build me a project from existing Node code" route.
Unfortunately, I currently get > 2000 compilation errors!
In the 'node_modules (node)' directory it is complaining of Duplicate identifiers (TS2300). These point toward 2 identical compiler.ts files located under the following directories.
\node_modules\bower\node_modules\insight\node_modules\inquirer\node_modules\rx\src\core\expressions\
\node_modules\bower\node_modules\inquirer\node_modules\inquirer\node_modules\rx\src\core\expressions\
Is there an NPM 'tidy up everything' option that I could you please?
You may try to clear npm cache by typing:
npm cache clear
The solution was to exclude the node_modules folder from the Project.