You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"plugin.install is not a function" when trying to add plugins to node script #2915
Trying to get less working from a node script but I get this error message when trying to add a plugin.
.../npm-scripts/node_modules/less/lib/less/plugin-manager.js:29
plugin.install(this.less, this);
^
TypeError: plugin.install is not a function
at PluginManager.addPlugin (.../npm-scripts/node_modules/less/lib/less/plugin-manager.js:29:12)
at PluginManager.addPlugins (.../npm-scripts/node_modules/less/lib/less/plugin-manager.js:19:18)
at Object.parse (.../npm-scripts/node_modules/less/lib/less/parse.js:34:27)
at Object.render (.../npm-scripts/node_modules/less/lib/less/render.js:25:18)
at .../npm-scripts/less-watch.js:27:14
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:405:3)
Tried with less-plugin-autoprefix and with less-plugin-clean-css. Any idea what could be causing this? I'm not doing anything strange (that I know of), my code is pretty much just:
varlessOptions={plugins: [lessAutoPrefix]};less.render(data,lessOptions,function(error,output){// do stuff});
Without the plugins option everything works fine. It also works fine when doing the same thing from the command line. Just installed all the modules so everything should be up to date.
@seven-phases-max I would say that based on the plugin documentation, plugins are actually not (strictly) following what Less is supporting, which is that a plugin returns an object with a certain signature, and not a function that can produce said object.
So I wouldn't say the example needs to be updated so much as the plugins need to be updated, as they're not returning a properly formed object with required properties. They're returning a function.
It might be reasonable for Less to attempt to create an instance if a function is returned, but I would still say that it's the plugin's responsibility to return a proper object signature when require'd.
Activity
seven-phases-max commentedon Jun 29, 2016
See the correct plugin instantiation examples in their docs. I.e.:
I.e. usually (actually for all plugins I know) you pass an instance/object of the plugin "class" (not the class itself).
Selfnote: probably the example needs a correction since it could be misleading (another example of the same confusion).
seven-phases-max commentedon Jun 29, 2016
Closing as not an issue.
matthew-dean commentedon Jun 29, 2016
@seven-phases-max I would say that based on the plugin documentation, plugins are actually not (strictly) following what Less is supporting, which is that a plugin returns an object with a certain signature, and not a function that can produce said object.
So I wouldn't say the example needs to be updated so much as the plugins need to be updated, as they're not returning a properly formed object with required properties. They're returning a function.
matthew-dean commentedon Jun 29, 2016
It might be reasonable for Less to attempt to create an instance if a function is returned, but I would still say that it's the plugin's responsibility to return a proper object signature when require'd.
josh18 commentedon Jun 29, 2016
Oh that makes sense, thanks! Yeah it was that documentation that confused me.