Я пытаюсь использовать внешний пакет:
npm install [python-shell][1]
Прямо сейчас у меня есть только базовый файл js с примером, который поставляется с пакетом:
console.log('hey in main.js')
var PythonShell = require('python-shell');
PythonShell.run('./my_script.py', function (err) {
if (err) throw err;
console.log('finished running python script');
});
Наряду с my_script.py
и т. д.
Когда я запускаю сервер, console.log говорит:
Uncaught TypeError: spawn is not a function
В index.js пакета python-shell порождение требуется правильно (аналогичный случай< /а>):
var spawn = require('child_process').spawn;
И позже он используется в пакете следующим образом:
this.childProcess = spawn(pythonPath, this.command, options);
Однако spawn
кажется функцией:
master$>node
> require('child_process')
{ ChildProcess:
{ [Function: ChildProcess]
super_:
{ [Function: EventEmitter]
EventEmitter: [Circular],
usingDomains: true,
defaultMaxListeners: 10,
init: [Function],
listenerCount: [Function] } },
fork: [Function],
_forkChild: [Function],
exec: [Function],
execFile: [Function],
spawn: [Function],
spawnSync: [Function: spawnSync],
execFileSync: [Function: execFileSync],
execSync: [Function: execSync] }
Поэтому я не уверен, почему консоль говорит, что это не функция.