Errors Compiling NodeJS project in VS2015 - node.js

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.

Related

Why does VS 2017 set node_modules folder to read only in .Net Core App?

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.

Update Node Version in Visual Studio 2017

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

Visual Studio npm scoped modules development?

I have very little experience with nodejs/typescript/visual studio development, and could use some advice and directions.
I'm starting a new vs2015 solution to develop several nodejs scoped modules.
My questions are:
How should I structure my project folders?
Is there a particular toolchain or workflow I should use?
Here's what I've hacked together so far:
The project seems to compile and run fine, but there were quite a few issues:
When something changes in #product/core, #product/analysis did not pick it up
Typescript error: Member not found
npm install/update does not work
Have to manually delete node_modules followed by "npm install"
Deleting/reinstalling node_modules gets past typescript compiler errors
But then Resharper has problem picking it up, unless I unload/reload the project
Have to manually delete node_modules followed by "npm install"
This is the way to go. I feel like these IDEs should support sync like atom-typescript does : https://github.com/TypeStrong/atom-typescript#sync and so does alm : https://basarat.gitbooks.io/alm/content/features/typescript.html#sync
Sadly the sync version of VS is a restart / a big enough fs change at the moment.

Activating extension `ms-vscode.wordcount` failed: Cannot find module 'd:/VSCode/vscode-wordcount/out/extension'

I try to build and debug an extension in Code.
I downloaded the sample of word-count from https://github.com/microsoft/vscode-wordcount.
When I clicked F5, ./out folder was not generated and I saw failure: Activating extension ms-vscode.wordcount failed: Cannot find module 'd:/VSCode/vscode-wordcount/out/extension'.
I found the post
https://github.com/Microsoft/vscode-go/issues/35
and I think this was because I failed to build the extension.
And I checked my path that node and npm were both set.
I found there were 2 possible issues.
I could not find .\node_modules folder in my extension folder. The folder structure is like
.vscode\
-- launch.json
-- settings.json
-- tasks.json
image\
test\
typings\
-- vscode-typings.d.ts
extension.ts
package.json
tsconfig.json
My node version is v0.12.2.
Could you give me some hints how to investigate the issue?
You probably downloaded directly from GitHub.
You will need to run npm install in your project's folder in order to create the node_modules directory and add the required dependencies.
If you simply want to install the extension to use it, you will also need to:
Move the folder to the correct place
npm install
OR
Install the built version directly from the Visual Studio Marketplace through the command pallet.

What is ".v8flags.3.14.5.9.{Name}"?

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.

Resources