Reputation: 166
I am working on an angular 2 project, and it is created by angular/CLI. After I opened my project by 'open -> folders,' the CPU usage been boosted to over 50% and everything becomes very slow. I tested it that the slowdown issue caused by 'node_moduls'. After I removed this folder, the IDE will back to normal.
However, in the project, I still need the 'node_moduls' folder, because I got error message everywhere if I removed the 'node_moduls' folder! Even an import from the angular core!
import { Component, OnInit, ViewChild, Input, Output, EventEmitter } from '@angular/core';)
Is any way to fix this problem?
As I can see, VS 2017 keep scanning my folders and files, and this process has been taken for 3 hours. Now the IDE still takes 30% usage of the CPU usage. I think it needs to port the VS code's folders management idea to VS 2017.
And I have checked the "exclude" option that should show on the right-click menu. However, it does not have any option for excluding the folder.
update: It has been a night, (I kept the VS2017 open) the VS still taking 30-40% CPU usage, and the scanning data still on 45% same with the first image.
Upvotes: 12
Views: 4137
Reputation: 9652
Instead of using
File -> Open -> Folder
use
File -> Open -> Web Site...
UPDATE:
or (thanks wodzu)
Solution > Add > Existing Website
Navigate to the location on your hard drive where the project lives and select its directory.
Since it is after all a web site that should work fine and it doesn't perform the scan.
I had the same issue but didn't want to modify the tsconfig.json file since that configuration is used by the angular cli tool which we use to compile the app.
Upvotes: 9
Reputation: 52867
Don't include node_modules
in your VS project because it takes forever to load.
In your tsconfig.json
file, you need to exclude the node_modules
folder from being compiled:
"compilerOptions":
...
},
"exclude": [
"node_modules"
]
Upvotes: 1
Reputation: 1191
In order to make angular2 node_modules work in Visual Studio I had to add "skipLibCheck": true to the tsconfig.json file.
{
"compilerOptions": {
...
"skipLibCheck": true
}
}
This will prevent the node_modules from being built with typescript.
Upvotes: 0
Reputation: 5332
Create a new Visual Studio project and add all these files excluding node_modules folder to that project by drag and drop to solution node in Solution Explorer. The node_modules folder should be there in your project's directory but not included in your VS project.
Upvotes: -1