less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
16.99k stars 3.41k forks source link

sys import doesn't work with nodejs 18 #4226

Closed OscarVanL closed 10 months ago

OscarVanL commented 10 months ago

To reproduce:

I am using the python-slim-bookworm docker container, which is based on debian 12 bookworm.

I've installed nodejs 18 via instructions at https://github.com/nodesource/distributions#installation-instructions

I installed less via:

npm install --global yarn less

Current behavior: When running less against my CSS file (bootstrap v2.1.1 CSS file available here) I get the following error:

#72 6.834 Building bundle: assets/base.css
#72 7.159 Failed, error was: less: subprocess returned a non-success result code: 1, stdout=, stderr=/service/node_modules/less/lib/less/index.js:46
#72 7.159         if (ctx.stack) { return sys.error(stylize(ctx.stack, 'red')) }
#72 7.159                                     ^
#72 7.159 
#72 7.159 TypeError: sys.error is not a function
#72 7.159     at Object.writeError (/service/node_modules/less/lib/less/index.js:46:37)
#72 7.159     at /service/node_modules/less/bin/lessc:118:22
#72 7.159     at finish (/service/node_modules/less/lib/less/parser.js:434:40)
#72 7.159     at /service/node_modules/less/lib/less/parser.js:94:48
#72 7.159     at /service/node_modules/less/lib/less/index.js:116:17
#72 7.159     at Object.parse (/service/node_modules/less/lib/less/parser.js:436:17)
#72 7.159     at /service/node_modules/less/lib/less/index.js:115:16
#72 7.159     at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)
#72 7.159 
#72 7.159 Node.js v18.17.1

Expected behavior:

Clearly an error is happening somewhere, but there's something wrong with the sys import. The common denominator is me updating nodejs to v18

Environment information:

iChenLei commented 10 months ago

@matthew-dean

matthew-dean commented 10 months ago

This code does not exist in the Less codebase or distributed runtime:

if (ctx.stack) { return sys.error(stylize(ctx.stack, 'red')) }

It's possible you're getting a real error, but surfacing the error is causing another error in a misconfigured Node environment, but Less does not utilize the sys module.

OscarVanL commented 10 months ago

Thanks, apologies for the misplaced issue. The error stack made it look like this was coming from less itself.

I think you're right that this was the result of a botched nodejs install. I unfortunately don't know what my exact fix was, but after spending time mucking around with my container's nodejs install it went away.

I will close the issue.