less.js icon indicating copy to clipboard operation
less.js copied to clipboard

lessc can't find plugins when not in cwd(?)

Open Franziskus1988 opened this issue 8 years ago • 12 comments

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

Franziskus1988 avatar Feb 27 '18 07:02 Franziskus1988

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

seven-phases-max avatar Feb 27 '18 20:02 seven-phases-max

grafik

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

Franziskus1988 avatar Feb 28 '18 08:02 Franziskus1988

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

mikekasprzak avatar Mar 06 '18 18:03 mikekasprzak

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

twiginteractive avatar Mar 06 '18 18:03 twiginteractive

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

mikekasprzak avatar Mar 06 '18 19:03 mikekasprzak

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

WraithKenny avatar Mar 09 '18 15:03 WraithKenny

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

luccasfraga avatar Mar 18 '18 00:03 luccasfraga

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

Franziskus1988 avatar Apr 11 '18 06:04 Franziskus1988

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

matthew-dean avatar Apr 11 '18 20:04 matthew-dean

@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.

Franziskus1988 avatar Apr 12 '18 13:04 Franziskus1988

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 avatar Apr 12 '18 13:04 Franziskus1988

@Franziskus1988 Please see #3200.

matthew-dean avatar Apr 21 '18 18:04 matthew-dean