首页 > 解决方案 > 从颤振启动节点服务器

问题描述

尝试直接从颤振应用程序启动节点服务这是我的代码

Process.run(
   'pm2',
   ['start', 'bin\www'],
   runInShell: true,
   includeParentEnvironment: true,
   workingDirectory: 'E:\Works\PosApi\posapi',
 ).then((result) {

   print("server started");
   // print(result.pid);
 }).catchError((err) {
   print(
       "node start- cath err");
 });

请告诉我如何 正确使用process.run()

以前我用过

std::string start = base_directory + "\\node\\nodestart.bat";
ShellExecuteA(NULL, "open",start.c_str(), NULL,NULL, SW_HIDE);

在 main.cpp/wWinMain() 和那个 bat 文件中添加了 ' cd /d E:\Works\PosApi\posapi & pm2 start bin/www ' 工作正常。

标签: flutterdart

解决方案


推荐阅读