Conflicts with requirejs
The latest version (1.5.0) of less.js conflicts with require.js (if loaded before require.js), causing the following error:
Uncaught TypeError: Object function require(a){return window.less[a.split("/")[1]]} has no method 'config'
It seems that this is only an issue with the minified version (less-1.5.0.min.js) because the minified JavaScript is not wrapped in an anonymous closure. Adding function(){ to the beginning and }()) to the end of the minified file.
Thankd, we updated our build system and must have broken this. I will fix this and do a new release soon.
Did we get a fix on this yet? I seem to have stumbled across the same issue.
I can confirm that I can get this working by using the non minified version, using the following code after my call to the require.js script:
<link rel="stylesheet/less" type="text/css" href="css/base.less" />
<script type="text/javascript">
less = {
env: "development",
async: false,
fileAsync: false,
poll: 1000,
functions: {},
dumpLineNumbers: "comments",
relativeUrls: false
};
</script>
<script src="js/libs/less-1.5.0.js" type="text/javascript"></script>
I still get an error but for development reasons I can continue to work and I will use NPM to finalise the code for live.
Uncaught Error: Mismatched anonymous define() module: function () { return less; }
http://requirejs.org/docs/errors.html#mismatch
Also seeing this issue.
Seeing it as well.
This is high priority to fix, will look at it next when I have time.
I have the same issue. Did you need help for debug?
There is a pull request open with a fix.. I have a couple of questions and then will merge if I get the right answers.
Sorry to be the bearer of unhappy news, but still not seeing it fixed here with 1.5.1.
Fail cases using require.js 2.1.9:
- Using
less.js, lots of errors of missing modules in require (Uncaught TypeError: Cannot call method 'appendChild' of nullandUncaught TypeError: Object #<Object> has no method 'module'. - Using
less.min.js,Uncaught Error: Mismatched anonymous define() module: function (){return w}in require.js, line 8.
Fail cases using require.min.js 2.1.9:
- Using
less.js, same as above - lots of errors of missing modules in require (Uncaught TypeError: Cannot call method 'appendChild' of null,Uncaught TypeError: Object #<Object> has no method 'module'. - Using
less.min.js:Uncaught TypeError: Object function require(a){return window.less[a.split("/")[1]]} has no method 'config'when callingrequire.config
As before, all the code works great without less.js.
Are you sure you updated?
https://github.com/less/less.js/blob/master/dist/less-1.5.1.min.js
we don't even have a function require any more...
Yep - and require's definitely in https://github.com/less/less.js/blob/master/dist/less-1.5.1.js.
But look at the 1.5.1 min file and look at your error - its the text from 1.5.0 also the non minified version was never broken.
Apologies, copypasta between the versions. Using less.min.js 1.5.1 and require.min.js 2.1.9, I get:
Uncaught Error: Mismatched anonymous define() module: function (){return w} in require.min.js line 8.
For clarity, this is when including less.js directly in the page, not loading it through require. Loading it through require.js works fine with the new version (and since it solves my problem and I'm not 100% sure of the dependencies / ordering when doing the inline pattern, I'm fine with saying this is not a bug.)
Thanks for the quick response, and apologies for the error!
I have had the same problem, but less-1.5.1.js (not minified, didn't try the other) fixed it.
I include it like this: link rel="stylesheet" type="text/css" href="styles/screen.less" media="screen" script src="javascript/lib/less-1.5.1.js" type="text/javascript" script data-main="javascript/app" src="javascript/lib/requirejs-2.1.9.js"
(removed tags)
don't know what skoczen faces for a problem, but for me it works.
@skoczen Read this. If you don't want to include less.js using Require.js API, try including the less.js before require.js as @grobmeier commented.
Including the less.js before require.js does not resolve the issue for me. I've resorted to using the un-minified version.
For me it works when using the not minified version of less less-1.5.1.js and including it bevor require.js is loaded:
works very fine and is absolutely fast...