我安装了nodejs
我安装了npm
我使用-g
选项
但是当我通过console和write命令less
运行nodejs时,有:
ReferenceError: less is not defined
at repl:1:2
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:98:17)
at emitKey (readline.js:1095:12)
我可以运行less
或lessc
,但可以运行nodejs
回答回复:
var less = require('less');
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 repl:1:12
at REPLServer.self.eval (repl.js:110:21)
at repl.js:249:20
at REPLServer.self.eval (repl.js:122:7)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
我需要它用于Assetic Symfony2
当我尝试做资产时:通过symfony2控制台转储我遇到的错误与我在nodejs“enviroment”中运行它时的错误...
答案 0 :(得分:1)
您需要模块:
var less = require('less')
http://lesscss.org/#usage在节点中有一个示例(搜索代码中的子部分用法):
var less = require('less');
less.render('.class { width: (1 + 1) }', function (e, css) {
console.log(css);
});