lukeed / kleur

The fastest Node.js library for formatting terminal text with ANSI colors~!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

do not define a valid './colors' target

iceycc opened this issue · comments

Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/postcss-loader/src/index.js):
Error: Loading PostCSS Plugin failed: Package exports for '/xxxx/node_modules/kleur' do not define a valid './colors' target

What is your Node.js version?

Anything between >= 13.0 and < 13.7 had an earlier version of exports map support that has since been removed and deprecated.

3q

@iceycc sorry, not sure what that means. Were you in that range?

What is your Node.js version?

Anything between >= 13.0 and < 13.7 had an earlier version of exports map support that has since been removed and deprecated.

Encountering the same problem. What is the recommended NPM version then ?

It is perfectly working with version 14.4.0. I had version 13.0.x

TLDR;
If you are using Node 13.0 - 13.6, you're going to have a bad time. These versions included early, experimental versions of native ESM support that are not compatible with the finalized behaviors found within 12.x, >13.7, and 14.x.

kleur and kleur/colors work in all versions of Node that are not within the 13.0 - 13.6 range.
These versions had experimental and/or incomplete exports map support, which are unable to parse and resolve the new fields correctly.

Put differently, any module that supports conditional ESM (this includes kleur) will fail to load with Node.js 13.0, 13.1, 13.2, 13.3, 13.4, 13.5, and 13.6. They will all resume working with 13.7 and later.

Now, kleur specifically, will still work for Node >= 6 and Node >= 13.7. Only the early 13.x versions will fail.

That said, odd-numbered Node.js releases are always experimental.
Once the next even version is released (14 in this case), you should always use it.
In this case, all of Node 13.x will be marked as "End of Life" comes July 2020.


Marking this as closed, but will pin the issue for easier visibility.