I'm writing an installer in Inno Setup which installs Node.js, extracts a zip file containing all the node project files, and then needs to install the node app using npm install.
The manual process consists of opening a command prompt, browsing to the directory where these files are (in my case extracted to its Program Files folder corresponding with the {app} folder setting), and then running that exact command line npm install --quiet. However, when doing this in Inno Setup, it fails...
function InstallNodeApp: Integer;
var
C: String;
begin
C:= 'npm install --quiet';
if not Exec(C, '', ExpandConstant('{app}'), SW_SHOWNORMAL, ewWaitUntilTerminated, Result) then begin
Result:= -1;
end;
end;
I've tried putting --quiet in the parameters as well as calling cmd.exe with this command line as a parameter, and many other combinations of attempts, but nothing is working - the execution just fails. The error I get is always The system cannot find the file specified..
How can I perform this node install while receiving the result/exit code?
npmis the executable, you should write something likeExec('npm', 'install --quiet', ExpandConstant('{app}'), SW_SHOWNORMAL, ewWaitUntilTerminated, Result), wherenpmis expected to be found either in{app}folder or e.g. path registered by thePATHenvironment variable. - TLamanpmisn't an executable, that's why I can't get it working. At least it's not an executable in this folder. I don't know anything aboutNode.jsandnpmbut I'm trying to replicate what's done in the command line with Inno Setup. - Jerry DodgeShellExecfunction in Inno Setup. For sure I can tell, if thatnpmis not an executable, useShellExecfunction. - TLama