我将所有的node.js依赖项都嵌入到项目和所有工作中,“少”除外。关于如何解决这个问题的任何想法?
这是我的配置:
assetic:
debug: %kernel.debug%
use_controller: false
node: "%assetic_node%"
node_paths:
- "%kernel.root_dir%/Resources/node_modules/"
- "%kernel.root_dir%/Resources/node_modules/less/node_modules/"
- "/usr/lib/node_modules/"
- "/usr/local/lib/node_modules/"
- "/opt/local/lib/node_modules/"
- "/root/node_modules/"
filters:
cssmin: ~
cssrewrite: ~
less:
apply_to: "\.less$"
bin: %kernel.root_dir%/Resources/node_modules/less/bin/lessc
coffee:
apply_to: "\.coffee$"
bin: %kernel.root_dir%/Resources/node_modules/coffee-script/bin/coffee
uglifyjs2:
apply_to: "\.js$"
bin: %kernel.root_dir%/Resources/node_modules/uglify-js/bin/uglifyjs
uglifycss:
apply_to: "\.css$"
bin: %kernel.root_dir%/Resources/node_modules/uglifycss/uglifycss
运行assetic:dump时出现以下错误:
[Assetic\Exception\FilterException]
An error occurred while running:
'/usr/bin/node' '/tmp/assetic_lessFnBKuF'
Error Output:
module.js:340
throw err;
^
Error: Cannot find module 'less'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/tmp/assetic_lessFnBKuF:1:74)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
最佳答案
首先,请确保您的系统中安装的组件及其依赖项较少:
npm install less -g
接下来,根据您的发行版,node_modules可以位于不同的位置,因此请检查您是否安装了较少的模块,以及在哪里安装了lessc。检查我的配置:
less:
bin: /usr/bin/lessc
node: /usr/bin/nodejs
node_paths: [/usr/lib/node_modules]
apply_to: "\.less$"