Skip to content

Commit 0be5a02

Browse files
committed
Create node_modules/@types after project creation
1 parent c39cdc7 commit 0be5a02

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Nodejs/Product/ProjectWizard/NpmWizardExtension.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using System.Collections.Generic;
44
using System.Diagnostics;
5+
using System.IO;
56
using Microsoft.VisualStudio.TemplateWizard;
67

78
namespace Microsoft.NodejsTools.ProjectWizard
@@ -23,6 +24,14 @@ public void ProjectFinishedGenerating(EnvDTE.Project project)
2324
Debug.Assert(project != null && project.Object != null);
2425
Debug.Assert(project.Object is INodePackageModulesCommands);
2526

27+
// Create the "node_modules/@types" folder before opening any files (which creates the
28+
// context for the project). This allows tsserver to start watching for type definitions
29+
// before any are installed (which is needed as "npm install" runs async, so the modules
30+
// usually aren't installed before the project context is loaded).
31+
var fullname = project.FullName;
32+
var projectFolder = Path.GetDirectoryName(fullname);
33+
Directory.CreateDirectory(Path.Combine(projectFolder, @"node_modules\@types"));
34+
2635
((INodePackageModulesCommands)project.Object).InstallMissingModulesAsync();
2736
}
2837

0 commit comments

Comments
 (0)