Thursday 15 May 2014

node.js - How to use less by "var less = require('less');" -



node.js - How to use less by "var less = require('less');" -

it's there utilize "less" this:

var less = require('less'); less.render('.class { width: (1 + 1) }', function (e, css) { console.log(css); });

in computer, said: "error: cannot find module 'less'".but had tried install "less"

"npm install less -g"

before utilize "require('less');"

relatively npm changed few things regarding global modules.

now, default, require(my_module) after installing globally not work, is, npm not check if my_module installed in global path.

what have 2 options:

if still want utilize global module, npm link less while beingness in project, create symbolic link less installed in global path. used in development, prodution advice not (as lose version control). install module locally npm install less in project folder. works both development , production, guessed, downloads less module again.

more on subject: https://www.npmjs.org/doc/cli/npm-link.html

node.js less

No comments:

Post a Comment