Blender命令行的Node.js产生?

我需要搅拌机命令行访问,虽然spawn但继续运行到一个ENOENT错误,很难找出缺less的东西。 示例应用程序中传递的命令行在terminal中运行。

以下是关于环境和我正在使用的示例脚本的一些细节。


环境(OSX El Capitan)

  1. 安装搅拌机2.76b与:

    brew install Caskroom/cask/blender

  2. 然后添加aliasbash_profile进行terminal访问:

    alias blender="/Applications/blender/Blender.app/Contents/MacOS/blender"

testing代码

 #!/usr/bin/env node var child_process = require('child_process'); var arguments = [ '-b', 'recipe.blend', '-o', 'test-#', '-f', 0 ]; console.log("values: ", arguments); var child = child_process.spawn('blender', arguments); child.stdout.on('data', function(data) { console.log('data out: ', data.toString()); }); child.stderr.on('data', function(data) { console.error('error out: ',data); }); child.on('close', function(code) { console.log('closing code: ' + code); }); // Raw command-line for terminal. (PASS) // blender -b recipe.blend -o test-# -f 0 

尝试改变child_process.spawn('blender',arguments); line to child_process.spawn('/ Applications / blender / Blender.app / Contents / MacOS / blender',arguments);. NodeJS不会使用你的bash别名,所以除非blender可执行文件在PATH中,否则它将无法find可执行文件,并且会抛出一个ENOENT。

另一个选项是调整节点的path,以包含搅拌机可执行文件的path。 您也可以将完整path作为环境variables传递给blender可执行文件。

干杯!