Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Programmatic usage] cannot read options of undefined #3533

Closed
aminya opened this issue Jul 8, 2020 · 2 comments
Closed

[Programmatic usage] cannot read options of undefined #3533

aminya opened this issue Jul 8, 2020 · 2 comments
Labels

Comments

@aminya
Copy link

aminya commented Jul 8, 2020

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.

@matthew-dean
Copy link
Member

@matthew-dean
Copy link
Member

@aminya You're using the API correctly. You've encountered a bug when importing via ES6 modules (instead of CommonJS). Fixing now, thanks for reporting.

matthew-dean added a commit to matthew-dean/less.js that referenced this issue Jul 15, 2020
matthew-dean added a commit to matthew-dean/less.js that referenced this issue Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants