@@ -12,6 +12,7 @@ public abstract class OutOfProcessNodeInstance : INodeServices {
1212 private object _childProcessLauncherLock ;
1313 private bool disposed ;
1414 private StringAsTempFile _entryPointScript ;
15+ private string _projectPath ;
1516 private string _commandLineArguments ;
1617 private Process _nodeProcess ;
1718 private TaskCompletionSource < bool > _nodeProcessIsReadySource ;
@@ -24,10 +25,11 @@ protected Process NodeProcess {
2425 }
2526 }
2627
27- public OutOfProcessNodeInstance ( string entryPointScript , string commandLineArguments = null )
28+ public OutOfProcessNodeInstance ( string entryPointScript , string projectPath , string commandLineArguments = null )
2829 {
2930 this . _childProcessLauncherLock = new object ( ) ;
3031 this . _entryPointScript = new StringAsTempFile ( entryPointScript ) ;
32+ this . _projectPath = projectPath ;
3133 this . _commandLineArguments = commandLineArguments ?? string . Empty ;
3234 }
3335
@@ -49,20 +51,20 @@ protected async Task EnsureReady() {
4951 lock ( this . _childProcessLauncherLock ) {
5052 if ( this . _nodeProcess == null || this . _nodeProcess . HasExited ) {
5153 var startInfo = new ProcessStartInfo ( "node" ) {
52- Arguments = this . _entryPointScript . FileName + " " + this . _commandLineArguments ,
54+ Arguments = " \" " + this . _entryPointScript . FileName + " \ " " + this . _commandLineArguments ,
5355 UseShellExecute = false ,
5456 RedirectStandardInput = true ,
5557 RedirectStandardOutput = true ,
5658 RedirectStandardError = true
5759 } ;
5860
59- // Append current directory to NODE_PATH so it can locate node_modules
61+ // Append projectPath to NODE_PATH so it can locate node_modules
6062 var existingNodePath = Environment . GetEnvironmentVariable ( "NODE_PATH" ) ?? string . Empty ;
6163 if ( existingNodePath != string . Empty ) {
6264 existingNodePath += ":" ;
6365 }
6466
65- var nodePathValue = existingNodePath + Path . Combine ( Directory . GetCurrentDirectory ( ) , "node_modules" ) ;
67+ var nodePathValue = existingNodePath + Path . Combine ( this . _projectPath , "node_modules" ) ;
6668 #if DNX451
6769 startInfo . EnvironmentVariables . Add ( "NODE_PATH" , nodePathValue ) ;
6870 #else
0 commit comments