Less.js: lessc can't find plugins when not in cwd(?)

Created on 27 Feb 2018  路  12Comments  路  Source: less/less.js

I have encountered a weird behaviour. When I use the less command line tool with a path it doesn't detect that the css-clean plugin is installed. Whereas when I use it in the folder where the node_modules are placed it works. See image:

grafik

bug high priority up-for-grabs

Most helpful comment

Bug was introduced in v3.x, so I had to downgrade to less 2.7.3

All 12 comments

Does this happen only with the clean-css plugin or ...?

grafik

@seven-phases-max Seems to be plugin independant.

I just started getting the above autoprefix error myself. I haven't touched my code in weeks.

Bug was introduced in v3.x, so I had to downgrade to less 2.7.3

I _just_ made the same discovery and fix. I didn't notice 3.x was out due to how the Releases page looked.

screenshot from 2018-03-06 13-59-28

@seven-phases-max it seems to be all plugins

I was in version 3.0.1 and it is not working. Just do this to solve.
See your lessc version:

lessc -v

after that enter:

npm install [email protected] -g

@seven-phases-max Any plan to fix this?

@Franziskus1988 If you or anyone else would like to submit a PR for this, that would be welcome.

@matthew-dean I've tried to fix it. Unfortunatelly the "failing import" test is failing. I don't know if there is a more convenient way to find the root folder of the node_modules installation. The test is now failing because I'm using a path which is relative to the less-node/index.js script position. In a node installation it works, but in the test enviroment it resolves to the wrong location. I could do an ugly fix for the test, but I actually don't know how to fix it nicely.

I think the problem is that process.cwd()/node_modules is added as path, although it should point to the node_modules folder of the less installation. Since process.cwd() always resolves to the current location in terminal the plugins, which are installed in the same package as less aren't found.

@Franziskus1988 Please see #3200.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matthew-dean picture matthew-dean  路  6Comments

BrianMulhall picture BrianMulhall  路  4Comments

renoth picture renoth  路  6Comments

MarkSG93 picture MarkSG93  路  4Comments

pknepper picture pknepper  路  3Comments