我安装了 nodejs 我安装了 npm 我用-g
选项安装了 less
但是当我通过控制台运行nodejs并编写命令less
时,有:
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
or 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 控制台执行assetic:dump 时,我遇到了与在nodejs“环境”中运行它时相同的错误......