从C#控制台应用程序运行npm init [英] Run npm init from the c# console app
本文介绍了从C#控制台应用程序运行npm init的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用以下代码从c#控制台应用程序运行 npm init命令:
I have try to run "npm init" command from the c# console app, using this code:
private void Execute(string command, string arg)
{
Process p = new Process();
p.StartInfo.FileName = command;
p.StartInfo.Arguments = arg;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.WorkingDirectory = @"E:\Work\";
p.Start();
p.WaitForExit();
}
Execute(@"C:\Program Files\nodejs\npm.cmd", "init");
但没有任何反应。运行我的应用程序后,我只有2个空行。请帮忙解决这个问题。
But nothing happening. I getting only 2 empty lines after the running my app. Please, help to resolve this problem.
推荐答案
看看我的运行 npm运行的示例dist
命令。
var psiNpmRunDist = new ProcessStartInfo
{
FileName = "cmd",
RedirectStandardInput = true,
WorkingDirectory = guiProjectDirectory
};
var pNpmRunDist = Process.Start(psiNpmRunDist);
pNpmRunDist.StandardInput.WriteLine("npm run dist & exit");
pNpmRunDist.WaitForExit();
这篇关于从C#控制台应用程序运行npm init的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文