calling node and uglifyjs from Php context

戏子无情 提交于 2019-12-10 19:01:19

问题


I'm trying out the JS minifier library UglifyJS2. I installed node.js on my mac using homebrew, and then uglifyjs through npm. It all works fine in the shell, node is found in the path and I manually added "uglifyjs" to the path so can find it just by typing "uglifyjs" (it is installed here: /usr/local/share/npm/lib/node_modules/uglify-js/bin/uglifyjs). This is done in ".bash_profile".

So, I can run everything fine in the terminal. I would now like to run it in a web context, in a Php page, using php's "exec". However, when I try to do that, exec returns status code '127', which I think means "command not found". I tried calling the complete path above too, but with the same result. My web server is running as the same user as i use in the shell.

The uglifyjs program starts like this, maybe that's a problem?

 #! /usr/bin/env node
 // -*- js -*-
 ...

Is there any way you know of to do this? Thanks


回答1:


A symlink in "/usr/bin" did the job:

sudo ln -s /usr/local/bin/node node



来源:https://stackoverflow.com/questions/18896515/calling-node-and-uglifyjs-from-php-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!