uncss Error: C.UTF-8: not a valid language tag

4.7k Views Asked by At

Hi I am trying to use UNCSS to remove unused styles from CSS for the first time and I am getting the following error:

Fontconfig warning: ignoring C.UTF-8: not a valid language tag

/home/ubuntu/.nvm/v0.10.35/lib/node_modules/uncss/node_modules/bluebird/js/main/async.js:43 fn = function () { throw arg; }; ^ Error: Fontconfig warning: ignoring C.UTF-8: not a valid language tag

at Socket.onStderr (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/uncss/node_modules/phridge/lib/spawn.js:79:28)
at Socket.emit (events.js:117:20)
at Socket.<anonymous> (_stream_readable.js:765:14)
at Socket.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:427:10)
at emitReadable (_stream_readable.js:423:5)
at readableAddChunk (_stream_readable.js:166:9)
at Socket.Readable.push (_stream_readable.js:128:10)
at Pipe.onread (net.js:529:21)

I even tried using Gulp and I have been searching for a solution and I am not understanding the output to fix it.

Any help to resolve this will be greatly appreciated.

-j

2

There are 2 best solutions below

1
On
LC_ALL=en_US.utf8

I had the same error. Typing this single line resolved the error.

I found en_US.utf8 in my list of locales locale -a as explained there: https://help.ubuntu.com/community/Locale

(This is a temporarily change, not permanent)

4
On

This is due to a bug in fontconfig. The bug is claimed to be fixed in 2013 so it is unlikely to get help from this side.

However you can just change to a different locale instead of C.UTF-8:

$ sudo locale-gen en_US en_US.UTF-8
$ sudo dpkg-reconfigure locales
$ sudo update-locale LANG=en_US

You can check if everything worked with the command:

$ locale

LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

In case you already did not:

$ npm install -g uncss

Now everything should work:

$ uncss http://yoururl.com > style.css