Random Javascript and typescript file content changes to weird characters, leads to compilation failure

In my project, randomly JavaScript files content in node_modules getting changed to weird characters. If I do clear node_modules and npm i again then it works fine. I am facing this issue frequently and consuming significant time of mine.

I tried checking the charset, this weird content file shows encoding as ANSI in notepad++. It didn't help even I changed the encoding to UTF-8. Windows is updated to latest and also tried re-installing git, nothing helped.

I noticed that not same js files I face problem with, totally random it is. Also I have faced problem with random typescript file as well. Same codebase however working fine for all other developers on their machine.

My machine Details:
OS: Windows 10    
Git: 2.31.1.windows.1
node: 10.23.0
Tortoise git: 2.12.0.0

Here is file content:

node_modules\@nrwl\cli\lib\output.js

$œ’m…Îmo“LÒDüÜ;˜%gÏ?wêÁÅ·øîùovH0õÉa‡5£Ú*î Ø’ÃÌlÍ››S iyä”rÕO7ª“ž%L]Ý×%±ºÇhk ¶«·÷>v1­HB£®±ßÞÚd\(eoIx¢>3´6BS%ÌØá“(
œÛf$Ãhý鿶åeÔŽôÚèHœ‚`ݶf{Fo©Yò¿Ôó@00uMb’z-ëìXI$&ÂgfÖú¶7Ó´Þu|'K.ÌoP
PÝÀùFË.Ðýoûò9B<~. ’ïÅË[’´˜Ë<Ù­„$¯•¢·ä{1¹A•.òbKxºL ¯Ý·'¯u8n5 ’ºe ,]ñH©–’ÆV¨ŒWwÃ$ùCƒel¹“|zys«™KŠi-ðqÊݬbk,wnGÿâ;¥  ~ÖeÉrÍ’‰ÜÔ~'1`V⦫¹-*[ÉñLÔKÄ'2@ŸÜþÐ仪 ²n‘Íß2¸Nß ˆÆ¶µG•¢ói/U¢µ'Eï@¦`H湘;J•¼¼ÜŽÅ+Jén#»¼‚6Ú´—ĹG•ü¡NÒGð'—Z!öáí¸‰Wi»NJ @óàšAûÜZ|ª[¨ï$q}iÒ·µQbtTEC$œ’m…Îmo“LÒDüÜ;˜%gÏ?wêÁÅ·øîùovH0õÉa‡5£Ú*î Ø’ÃÌlÍ››S iyä”rÕO7ª“ž%L]Ý×%±ºÇhk ¶«·÷>v1­HB£®±ßÞÚd\(eoIx¢>3´6BS%ÌØá“(
œÛf$Ãhý鿶åeÔŽôÚèHœ‚`ݶf{Fo©Yò¿Ôó@00uMb’z-ëìXI$&ÂgfÖú¶7Ó´Þu|'K.ÌoP
PÝÀùFË.Ðýoûò9B<~. ’ïÅË[’´˜Ë<Ù­„$¯•¢·ä{1¹A•.òbKxºL ¯Ý·'¯u8n5 ’ºe ,]ñH©–’ÆV¨ŒWwÃ$ùCƒel¹“|zys«™KŠi-ðqÊݬbk,wnGÿâ;¥  ~ÖeÉrÍ’‰ÜÔ~'1`V⦫¹-*[ÉñLÔKÄ'2@ŸÜþÐ仪 ²n‘Íß2¸Nß ˆÆ¶µG•¢ói/U¢µ'Eï@¦`H湘;J•¼¼ÜŽÅ+Jén#»¼‚6Ú´—ĹG•ü¡NÒGð'—Z!öáí¸‰Wi»NJ @óàšAûÜZ|ª[¨ï$q}iÒ·µQbtTEC$œ’m…Îmo“LÒDüÜ;˜%gÏ?wêÁÅ·øîùovH0õÉa‡5£Ú*î Ø’ÃÌlÍ››S iyä”rÕO7ª“ž%L]Ý×%±ºÇhk ¶«·÷>v1­HB£®±ßÞÚd\(eoIx¢>3´6BS%ÌØá“(
œÛf$Ãhý鿶åeÔŽôÚèHœ‚`ݶf{Fo©Yò¿Ôó@00uMb’z-ëìXI$&ÂgfÖú¶7Ó´Þu|'K.ÌoP
PÝÀùFË.Ðýoûò9B<~. ’ïÅË[’´˜Ë<Ù­„$¯•¢·ä{1¹A•.òbKxºL ¯Ý·'¯u8n5 ’ºe ,]ñH©–’ÆV¨ŒWwÃ$ùCƒel¹“|zys«™KŠi-ðqÊݬbk,wnGÿâ;¥  ~ÖeÉrÍ’‰ÜÔ~'1`V⦫¹-*[ÉñLÔKÄ'2@ŸÜþÐ仪 ²n‘Íß2¸Nß ˆÆ¶µG•¢ói/U¢µ'Eï@¦`H湘;J•¼¼ÜŽÅ+Jén#»¼‚6Ú´—ĹG•ü¡NÒGð'—Z!öáí¸‰Wi»NJ @óàšAûÜZ|ª[¨ï$q}iÒ·µQbtTEC$œ’m…Îmo“LÒDüÜ;˜%gÏ?wêÁÅ·øîùovH0õÉa‡5£Ú*î Ø’ÃÌlÍ››S iyä”rÕO7ª“ž%L]Ý×%±ºÇhk ¶«·÷>v1­HB£®±ßÞÚd\(eoIx¢>3´6BS%ÌØá“(
œÛf$Ãhý鿶åeÔŽôÚèHœ‚`ݶf{Fo©Yò¿Ôó@00uMb’z-ëìXI$&ÂgfÖú¶7Ó´Þu|'K.ÌoP
PÝÀùFË.Ðýoûò9B<~. ’ïÅË[’´˜Ë<Ù­„$¯•¢·ä{1¹A•.òbKxºL ¯Ý·'¯u8n5 ’ºe ,]ñH©–’ÆV¨ŒWwÃ$ùCƒel¹“|zys«™KŠi-ðqÊݬbk,wnGÿâ;¥  ~ÖeÉrÍ’‰ÜÔ~'1`V⦫¹-*[ÉñLÔKÄ'2@ŸÜþÐ仪 ²n‘Íß2¸Nß ˆÆ¶µG•¢ói/U¢µ'Eï@¦`H湘;J•¼¼ÜŽÅ+Jén#»¼‚6Ú´—ĹG•ü¡NÒGð'—Z!öáí¸‰Wi»NJ @óàšAûÜZ|ª[¨ï$q}iÒ·µQbtTEC$œ’m…Îmo“LÒDüÜ;˜%gÏ?wêÁÅ·øîùovH0õÉa‡5£Ú*î Ø’ÃÌlÍ››S iyä”rÕO7ª“ž%L]Ý×%±ºÇhk ¶«·÷>v1­HB£®±ßÞÚd\(eoIx¢>3´6BS%ÌØá“(
œÛf$Ãhý鿶åeÔŽôÚèHœ‚`ݶf{Fo©Yò¿Ôó@00uMb’z-ëìXI$&ÂgfÖú¶7Ó´Þu|'K.ÌoP
PÝÀùFË.Ðýoûò9B<~. ’ïÅË[’´˜Ë<Ù­„$¯•¢·ä{1¹A•.òbKxºL ¯Ý·'¯u8n5 ’ºe ,]ñH©–’ÆV¨ŒWwÃ$ùCƒel¹“|zys«™KŠi-ðqÊݬbk,wnGÿâ;¥  ~ÖeÉrÍ’‰ÜÔ~'1`V⦫¹-*[ÉñLÔKÄ'2@ŸÜþÐ仪 ²n‘Íß2¸Nß ˆÆ¶µG•¢ói/U¢µ'Eï@¦`H湘;J•¼¼ÜŽÅ+Jén#»¼‚6Ú´—ĹG•ü¡NÒGð'—Z!öáí¸‰Wi»NJ @óàšAûÜZ|ª[¨ï$q}iÒ·µQbtTEC$œ’m…Îmo“LÒDüÜ;˜%gÏ?wêÁÅ·øîùovH0õÉa‡5£Ú*î Ø’ÃÌlÍ››S iyä”rÕO7ª“ž%L]Ý×%±ºÇhk ¶«·÷>v1­HB£®±ßÞÚd\(eoIx¢>3´6BS%ÌØá“(
œÛf$Ãhý鿶åeÔŽôÚèHœ‚`ݶf{Fo©Yò¿Ôó@00uMb’z-ëìXI$&ÂgfÖú¶7Ó´Þu|'K.ÌoP
PÝÀùFË.Ðýoûò9B<~. ’ïÅË[’´˜Ë<Ù­„$¯•¢·ä{1¹A•.òbKxºL ¯Ý·'¯u8n5 ’ºe ,]ñH©–’ÆV¨ŒWwÃ$ùCƒel¹“|zys«™KŠi-ðqÊݬbk,wnGÿâ;¥  ~ÖeÉrÍ’‰ÜÔ~'1`V⦫¹-*[ÉñLÔKÄ'2@ŸÜþÐ仪 ²n‘Íß2¸Nß ˆÆ¶µG•¢ói/U¢µ'Eï@¦`H湘;J•¼¼ÜŽÅ+Jén#»¼‚6Ú´—ĹG•ü¡NÒGð'—Z!öáí¸‰Wi»NJ @óàšAûÜZ|ª[¨ï$q}iÒ·µQbtTEC$œ’m…Îmo“LÒDüÜ;˜%gÏ?wêÁÅ·øîùovH0õÉa‡5£Ú*î Ø’ÃÌlÍ››S iyä”rÕO7ª“ž%L]Ý×%±ºÇhk ¶«·÷>v1­HB£®±ßÞÚd\(eoIx¢>3´6BS%ÌØá“(
œÛf$Ãhý鿶åeÔŽôÚèHœ‚`ݶf{Fo©Yò¿Ôó@00uMb’z-ëìXI$&ÂgfÖú¶7Ó´Þu|'K.ÌoP
PÝÀùFË.Ðýoûò9B<~. ’ïÅË[’´˜Ë<Ù­„$¯•¢·ä{1¹A•.òbKxºL ¯Ý·'¯u8n5 ’ºe ,]ñH©–’ÆV¨ŒWwÃ$ùCƒel¹“|zys«™KŠi-ðqÊݬbk,wnGÿâ;¥  ~ÖeÉrÍ’‰ÜÔ~'1`V⦫¹-*[ÉñLÔKÄ'2@ŸÜþÐ仪 ²n‘Íß2¸Nß ˆÆ¶µG•¢ói/U¢µ'Eï@¦`H湘;J•¼¼ÜŽÅ+Jén#»¼‚6Ú´—ĹG•ü¡NÒGð'—Z!öáí¸‰Wi»NJ @óàšAûÜZ|ª[¨ï$q}iÒ·µQbtTEC$œ’m…Îmo“LÒDüÜ;˜%gÏ?wêÁÅ·øîùovH0õÉa‡5£Ú*î Ø’ÃÌlÍ››S iyä”rÕO7ª“ž%L]Ý×%±ºÇhk ¶«·÷>v1­HB£®±ßÞÚd\(eoIx¢>3´6BS%ÌØá“(
œÛf$Ãhý鿶åeÔŽôÚèHœ‚`ݶf{Fo©Yò¿Ôó@00uMb’z-ëìXI$&ÂgfÖú¶7Ó´Þu|'K.ÌoP
PÝÀùFË.Ðýoûò9B<~. ’ïÅË[’´˜Ë<Ù­„$¯•¢·ä{1¹A•.òbKxºL ¯Ý·'¯u8n5 ’ºe ,]ñH©–’ÆV¨ŒWwÃ$ùCƒel¹“|zys«™KŠi-ðqÊݬbk,wnGÿâ;¥  ~ÖeÉrÍ’‰ÜÔ~'1`V⦫¹-*[ÉñLÔKÄ'2@ŸÜþÐ仪 ²n‘Íß2¸Nß ˆÆ¶µG•¢ói/U¢µ'Eï@¦`H湘;J•¼¼ÜŽÅ+Jén#»¼‚6Ú´—ĹG•ü¡NÒGð'—Z!öáí¸‰Wi»NJ @óàšAûÜZ|ª[¨ï$q}iÒ·µQbtTEC$œ’m…Îmo“LÒDüÜ;˜%gÏ?wêÁÅ·øîùovH0õÉa‡5£Ú*î Ø’ÃÌlÍ››S iyä”rÕO7ª“ž%L]Ý×%±ºÇhk ¶«·÷>v1­HB£®±ßÞÚd\(eoIx¢>3´6BS%ÌØá“(
œÛf$Ãhý鿶åeÔŽôÚèHœ‚`ݶf{Fo©Yò¿Ôó@00uMb’z-ëìXI$&ÂgfÖú¶7Ó´Þu|'K.ÌoP
PÝÀùFË.Ðýoûò9B<~. ’ïÅË[’´˜Ë<Ù­„$¯•¢·ä{1¹A•.òbKxºL ¯Ý·'¯u8n5 ’ºe ,]ñH©–’ÆV¨ŒWwÃ$ùCƒel¹“|zys«™KŠi-ðqÊݬbk,wnGÿâ;¥  ~ÖeÉrÍ’‰ÜÔ~'1`V⦫¹-*[ÉñLÔKÄ'2@ŸÜþÐ仪 ²n‘Íß2¸Nß ˆÆ¶µG•¢ói/U¢µ'Eï@¦`H湘;J•¼¼ÜŽÅ+Jén#»¼‚6Ú´—ĹG•ü¡NÒGð'—Z!öáí¸

enter image description here

Code compilation output

$→œ’m…Îmo“LÒDüÜ;˜%gÏ?wêÁÅ·↓ø▬îùovH0õÉa‡5£Ú*î Ø’ÃÌlÍ››S iy☺ä”rÕO7ª“ž%L]Ý×%±º∟Çhk ¶«·÷>v1­HB£®±♣ßÞÚd\(‼e♂o▼Ix¢>3´☺6BS%ÌØá“(⌂
 ^

SyntaxError: Invalid or unexpected token
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (D:\A_UI_ionTrader\ngIonTrader\ionTrader\node_modules\@nrwl\cli\lib\init-global.js:6:18)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

Please help.



Read more here: https://stackoverflow.com/questions/67394945/random-javascript-and-typescript-file-content-changes-to-weird-characters-leads

Content Attribution

This content was originally published by Trans at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: