【发布时间】:2016-03-11 00:15:45
【问题描述】:
我无法识别公共目录 c:\TEMP\todos\.meteor\local\build\programs\server\public\main.py 中文件的路径。 Meteor 抱怨文件或目录不存在。已经搜索过有关类似问题的其他帖子(例如,Reading files from a directory inside a meteor app)但没有帮助。
这是错误信息。
=> Your application has errors. Waiting for file change.
=> Modified -- restarting.
=> Meteor server restarted
W20151206-04:05:57.893(-5)? (STDERR) Error inside the Async.runSync: ENOENT, no such file or directory 'c:\TEMP\todos\.meteor\local\build\programs\server\public'
客户端代码
Meteor.call('runPython', function(err, response) {
if(err){
} else {
console.log(response);
}
})
服务器代码
Meteor.startup( function (){
Meteor.methods({
runPython: function (){
var PythonShell = Meteor.npmRequire('python-shell');
var fs = Meteor.npmRequire('fs');
var runPython = Async.runSync(function (done){
var files = fs.readdirSync('./public/');
// PythonShell.run('main.py', function ... was tried first but Meteor complained that "main.py doesn't exist". So below is a different attempt.
var py = _(files).reject(function(fileName){
return fileName.indexOf('.py') <0;
})
PythonShell.run(py, function (err) {
// PythonShell.run(path.join(py,"main.py") ... was also tried but resulted in the same error
if (err) throw err;
console.log('script running failed');
});
})
return "Success";
}
})
})
【问题讨论】:
-
仅供参考:
public应该在 Meteor 应用程序的根目录下,而不是在server下。从客户端public目录将解析为/,而不是/public
标签: javascript node.js meteor