简体   繁体   English

php在Windows 7上通过nodejs使用lessc编译较少的文件

[英]php compile less file using lessc via nodejs on windows 7

I am trying to compile less file using php, and I am trying to use lessc which I installed as nodejs module on my windows 7 我正在尝试使用php编译较少的文件,并且我尝试使用在Windows 7中作为nodejs模块安装的lessc

I am trying to do : 我正在尝试:

$command = lessc %s -compress %s 

via 通过

exec($command, $output);

and if I do this via cmd it works fine but I can't execute it using above command in php :(. 如果我通过cmd做到这一点,它可以正常工作,但是我无法使用php :(中的上述命令来执行它。

the path which works are relative to my drive (E:/wamp/my-project/less/hello.less) 起作用的路径是相对于我的驱动器的(E:/wamp/my-project/less/hello.less)

Any body knows what I am doing wrong? 任何人都知道我在做什么错吗?

Note: I know how I can use lessphp compiler, and I am already using it but I would like to use lessc module installed via nodejs . 注意:我知道如何使用lessphp编译器,并且我已经在使用它,但是我想使用通过nodejs安装的lessc模块。

Are you able to get the output of the command when it fails? 失败时能否获得命令的输出? It's possible that lessc isn't directly available in your path. lessc可能在您的路径中不直接可用。 If you installed it via npm install -g then it will likely be in %appdata%, which is a user path'd directory. 如果是通过npm install -g则它可能位于%appdata%中,这是用户路径的目录。 It really depends upon how the php process gets initiated, but my guess is that this path won't work. 这实际上取决于如何启动php进程,但是我猜测这条路径将无法工作。

If I need to use an npm module like this, I usually npm install it locally, and invoke the path to lessc.cmd from a relative path to my program. 如果需要使用这样的npm模块,通常我会在本地npm install它,并从程序的相对路径中调用lessc.cmd的路径。

Hope this helps. 希望这可以帮助。 Happy coding! 编码愉快!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM