Bug 16591 – Spawn process on windows fails for npm start
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2016-10-04T17:01:00Z
Last change time
2016-10-09T09:15:11Z
Assigned to
nobody
Creator
andre
Comments
Comment #0 by andre — 2016-10-04T17:01:47Z
Following example is working fine on linux but on windows spawn process fails with an exception.
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.
On windows spawn process is not able to execute > npm start.
On Ubuntu Linux the application works fine.
To install node on ubuntu:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
For windows there is setup routine available on nodejs.org
Comment #1 by dfj1esp02 — 2016-10-05T09:55:00Z
CreateProcessW supports running only executables, and I suppose npm is a script. Try to run the actual V8 interpreter executable.
Comment #2 by dfj1esp02 — 2016-10-05T10:11:55Z
Ah, it's a batch file, then use spawnShell("npm.cmd start",...)