Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs - .node_libraries/ for www-data

Tags:

php

node.js

I want to use uglifyjs (https://github.com/mishoo/UglifyJS) from my PHP application. UglifyJS is built using Nodejs, so I need a .node_libraries/ dir in my homedir (/home/peppe).

I want to execute uglifyjs by shell_exec() in PHP. But where am I supposed to add the .node_libraries/ dir since www-data user doesn't have a home dir?


Addition: I solved it. The solution was to set NODE_PATH and execute the command like this in PHP: shell_exec('NODE_PATH="/opt/www_node_libraries/"; export NODE_PATH; uglifyjs options filename');

like image 923
Erik Avatar asked May 09 '11 22:05

Erik


1 Answers

Quoting the OP and @Bill so we can get this removed from unanswered list.

Addition: I solved it.
The solution was to set NODE_PATH and execute the command like this in PHP:

shell_exec('NODE_PATH="/opt/www_node_libraries/"; export NODE_PATH; uglifyjs options filename');
like image 52
dynamic Avatar answered Oct 06 '22 07:10

dynamic