为什么Meteor中的shell代码在服务器上运行良好?

时间:2015-02-07 14:48:01

标签: node.js shell meteor

我让我的meteor应用程序在我的Mac上运行一个shell代码(比如mkdir foo),但是当我在我的VPS上部署它时,它无法运行。我使用Meteor和MUP来部署它。现在我不知道我知道如何在我的VPS上调试它。

来到DEMO代码:

if (Meteor.isServer) {
  Meteor.startup(function () {
    Meteor.methods({
      setBlogList: function(){
        var run = Npm.require('child_process');
        run.exec('mkdir ~/memeda');
    }
    });
  });
}

1 个答案:

答案 0 :(得分:1)

你是什么意思“它无法运行”?你有什么错误信息,如果有的话?

如果代码无法创建目录,可能是因为用户mup在其下运行它没有对它认为的主目录的任何写入权限。

使用path.resolve('~/memeda')查看该目录在文件系统中实际解析的内容,然后从那里开始。请在mup documentation中查看如何设置路径(例如app设置)。