在php中执行gulp返回错误,但在shell中工作

从php脚本执行gulp有一个奇怪的问题。 testing:

browser: http://server.com/pull.php <- does not work shell: php pull.php <- works shell: gulp <- works 

这是我的设置:

 Ubuntu 12.04.5 LTS Node v5.6.0 PHP 5.5.30-1+deb.sury.org~precise+1 (cli) (built: Oct 4 2015 16:14:34) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies 

这里是package.json中的包:

 "gulp": "^3.9.1", "gulp-concat": "^2.6.0", "gulp-less": "^3.0.5", "gulp-rename": "^1.2.2", "gulp-uglify": "^1.5.2", "gulp-uglifycss": "^1.0.6", "gulp-watch": "^4.3.5" 

它运行完美,当我从壳运行这个,但在php作为web服务器运行时返回错误:

 node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ TypeError: Object #<Object> has no method 'existsSync' at /usr/local/lib/node_modules/gulp/node_modules/liftoff/lib/find_config.js:21:10 at Liftoff.buildEnvironment (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:67:20) at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:192:32) at /usr/local/lib/node_modules/gulp/node_modules/liftoff/node_modules/flagged-respawn/index.js:17:3 at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:185:9) at /usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:159:9 at /usr/local/lib/node_modules/gulp/node_modules/v8flags/index.js:99:14 at Array.0 (/usr/local/lib/node_modules/gulp/node_modules/v8flags/index.js:38:7) at EventEmitter._tickCallback (node.js:192:41) 

命令来运行它很简单: passthru('gulp 2>&1'); 。 我最不知道什么是错的,文件的所有者,networking服务器(nginx运行)用户和git所有者是同一个用户名为git 。 尝试各种不同的东西,使bash脚本从PHP运行,但没有运气。 我猜我缺less一些系统variables?

在此先感谢,让我知道如果你需要更多的信息。

事实certificate,节点不能很好地发挥作用。 我的解决scheme

 passthru('node ./node_modules/gulp/bin/gulp.js 2>&1'); 

我无法解释为什么,只是尝试了几个随机的想法,那个人工作。 有一件事困扰我,但为什么我不能得到充分的信息在git pull ? 我只是得到:

 Updating dcd958f..db05960