Re: Cannot spawn process: npm start
On Tuesday, 4 October 2016 at 18:41:16 UTC, FreeSlave wrote: On Tuesday, 4 October 2016 at 17:02:34 UTC, Adam D. Ruppe wrote: On Tuesday, 4 October 2016 at 16:55:22 UTC, Andre Pany wrote: Spawn process is working fine on linux, only on windows it doesn't work. I will create a bug report. This isn't really a bug if it is a cmd file like the other poster said... cmd files are scripts that need to be run through the interpreter. shellExec probably handles it, or you could spawnProcess "cmd" with the npm being an argument to it. There's no shellExec, but executeShell. spawnShell would fit better since author used spawnProcess in original post. Whether spawnProcess should handle .bat and .cmd is a matter of function design really. Actually I would like to treat spawnProcess more like double-click on application and double-click works for scripts on windows. So there will be no special code for phobos user to handle this case. I found the trick. If I change args to ["npm.cmd", "start"] it will work. I do not know whether spawnProcess should handle npm vs npm.cmd automatically. Should I close the bug report? In the beginning I used executeShell, but had some issue to stop the started server applications. Somehow the server applications weren't stopped although kill and wait were executed. The same scenario is working fine with spawnProcess. Kind regards André
Re: Cannot spawn process: npm start
On Tuesday, 4 October 2016 at 17:02:34 UTC, Adam D. Ruppe wrote: On Tuesday, 4 October 2016 at 16:55:22 UTC, Andre Pany wrote: Spawn process is working fine on linux, only on windows it doesn't work. I will create a bug report. This isn't really a bug if it is a cmd file like the other poster said... cmd files are scripts that need to be run through the interpreter. shellExec probably handles it, or you could spawnProcess "cmd" with the npm being an argument to it. There's no shellExec, but executeShell. spawnShell would fit better since author used spawnProcess in original post. Whether spawnProcess should handle .bat and .cmd is a matter of function design really. Actually I would like to treat spawnProcess more like double-click on application and double-click works for scripts on windows. So there will be no special code for phobos user to handle this case.
Re: Cannot spawn process: npm start
On Tuesday, 4 October 2016 at 16:55:22 UTC, Andre Pany wrote: Spawn process is working fine on linux, only on windows it doesn't work. I will create a bug report. This isn't really a bug if it is a cmd file like the other poster said... cmd files are scripts that need to be run through the interpreter. shellExec probably handles it, or you could spawnProcess "cmd" with the npm being an argument to it.
Re: Cannot spawn process: npm start
On Tuesday, 4 October 2016 at 13:52:23 UTC, FreeSlave wrote: On Tuesday, 4 October 2016 at 12:58:19 UTC, Andre Pany wrote: Hi, I need to call a Node application. node and npm are in windows path variable. I have following folder structure: ./app.d ./js/helloworld.js ./js/package.json [...] npm is .cmd file on Windows. Maybe this is issue. Looks like cmd.exe knows how to deal with them, while CreateProcess does not. I just tried the D coding on Ubuntu Sub System for windows. Spawn process is working fine on linux, only on windows it doesn't work. I will create a bug report. Kind regards André
Re: Cannot spawn process: npm start
On Tuesday, 4 October 2016 at 13:18:45 UTC, Adam D. Ruppe wrote: Are you sure npm is in the path? From your shell, do `which npm` and see where it is coming from, you might want to use the full path to spawn process. Yes, npm is in path. From all directories I can execute npm/node (--version) and receive a valid result. I can execute npm start within folder "js" in both consoles, git bash and windows cmd. There it works fine. On windows cmd which is not a known command. On git bash I receive as result: /c/Program Files/nodejs/npm Kind regards André
Re: Cannot spawn process: npm start
On Tuesday, 4 October 2016 at 12:58:19 UTC, Andre Pany wrote: Hi, I need to call a Node application. node and npm are in windows path variable. I have following folder structure: ./app.d ./js/helloworld.js ./js/package.json [...] npm is .cmd file on Windows. Maybe this is issue. Looks like cmd.exe knows how to deal with them, while CreateProcess does not.
Re: Cannot spawn process: npm start
Are you sure npm is in the path? From your shell, do `which npm` and see where it is coming from, you might want to use the full path to spawn process.
Cannot spawn process: npm start
Hi, I need to call a Node application. node and npm are in windows path variable. I have following folder structure: ./app.d ./js/helloworld.js ./js/package.json content of helloworld.js: console.log('hello world'); content of package.json: { "name": "test", "version": "1.0.0", "scripts": { "start": "node helloworld.js" } } content of app.d import std.process, std.path, std.file, std.stdio; void main() { string workDir = buildPath(thisExePath.dirName, "js"); string[] args = ["npm", "start"]; spawnProcess(args, std.stdio.stdin, std.stdio.stdout, std.stdio.stderr, null, std.process.Config.none, workDir); } I compile with dmd and then start the application. I always receive an error "Failed to spawn new process". As I specify the work directory, this should work, or? Kind regards André