0
votes

I deal with an error with the installation of nodejs and less on a Centos 7 server.

My aim is to install a Symfony2 application on a new server (Centos 7). My application use less files, including for Twitter Bootstrap.

For Symfony2, I declare the following :

    assetic:
    filters:
        cssrewrite: ~
        less:
            node: "/usr/local/bin/node"
            node_paths: ["/usr/local/lib/node_modules"]
            apply_to: "\.less$"

I followed this tutorial for the installation of node/npm and after less : https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-a-centos-7-server.

Everything seems to bve alright, the command node -v works like npm -v. I launch this command for less :

sudo npm install less -g

I test a simple compilation of a style.less file in command line like :

$ lessc style.less style.css

No problem.

BUT when I run the Symfony2 command :

php app/console assetic:dump --env=prod

I have the error bellow :

[Assetic\Exception\FilterException]

An error occurred while running:

'/usr/local/bin/node' '/tmp/assetic_lessKtMIZV'
  Error Output:
  module.js:338
      throw err;
        ^

Error: Cannot find module 'less' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:278:25) at Module.require (module.js:365:17) at require (module.js:384:17) at Object. (/tmp/assetic_lessKtMIZV:1:74) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10)

Node is well in /usr/local/bin/node

Node modules are well in : /usr/local/lib/node_modules

Any idea ? Thanks

1
It can't find less module. So try to install it locally without the -g. "npm i less" inside your app folder - Molda

1 Answers