Skip to content

[Programmatic usage] cannot read options of undefined #3533

@aminya

Description

@aminya

I am trying to use Less in a programmatic fashion inside node, but I get this error:

import less from 'less'
let lessRender = less.render;

// then I call lessRender on something
let y = lessRender(`
body {
    a: 1;
    b: 2;
    c: 30;
    d: 4;
}`, {sourceMap: {}},  function(error, output) {return output})
TypeError: Cannot read property 'options' of undefined

what am I doing wrong? The documentation is vaguely written, and there is no tutorial on how to import the library and its functions. It also says API coming soon!
http://lesscss.org/usage/#programmatic-usage
Also, a couple of links don't work for example: https://github.com/less/less.js/blob/master/lib/less/environment/environment-api.js

Note: the code is written for less 2 inside Node, and I am trying to update it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions