Considering China was completely devastated by WWII and the civil war and that, as far as I know, both the Kuomintang and the Communists were technologically inferior to the Japanese, how were they able to modernise enough in a few years to push back the Americans in the Korean War?
It's useful to note how understrength the UN forces, especially the US forces, were even 5 years after WWII. The immense draw down had demobilized most of our strategic forces - the Navy was a shadow of itself, the Marines, though better equipped due to force planning, had next to no amphibious capability, and the forces in Korea were undersupplied, understrength, and outgunned by the KPA. Things were massively improved by the time of the Incheon breakout, but there was still a disparity in forces when the Chinese got involved.
Most of the initial Chinese successes relied on strategic blindness by MacArthur. Any action north of the 38th parallel was predicated on the belief that the Chinese would not intervene - this was exacerbated by poor intelligence about PLA (PVA, in this case, since it was a volunteer army) troop dispositions around the Korean peninsula. The PVA had excellent march discipline and effective camouflage that allowed them to move into position with relative ease and undetected. They overwhelmed the overstretched and under-supplied ROK forces they came across, and used strategic and tactical surprise to outmaneuver the Americans at places like the Chosin Reservoir.
After their initial successes, however, strain began to show in their logistical capabilities; the length of the Korean peninsula was tough to resupply with their meager logistics train, and the lack of air cover south of the Yalu river meant standing still was a dangerous proposition for any sizeable PVA formation.
By March of '51, Mao had convinced Stalin that the struggle was worthwhile (and according to a recent history of Zhou Enlai, he was impressed by their efforts) and the Soviets brought enough materiel support to counter the UN advantages - air power, including the fearsome MiG-15, some 6,000 trucks, and Soviet anti-aircraft units. The MiG in particular was a rude invitee to the party, with a higher combat ceiling than the F-80's and other contemporary jet fighters, and the 37mm cannon played absolute hell on the B-29 formations being deployed by the UN (basically the US).
Rough parity was reached by mid-1951, with MacArthur being replaced by a more strategically cautious commander and the concern that the USSR (which had substantial ground and naval assets in the Far East) keeping the UN forces from doing anything too drastic. It should be noted that during the war, the USAF pounded North Korea into literal dust; the firebombing and conventional bombing campaigns more or less destroyed any building of substance in North Korea, with whole cities being removed from the target list due to there being nothing left to hit.
Stokesbury, James - A Short History of the Korean War (1990)
As a minor addendum to /u/el_pinata's answer, while the war against Japan had essentially destroyed the Nationalist military and government, the Communists had spent the war developing their strategic, operational and tactical doctrine under the leadership of Mao Zedong, Zhu De and Peng Dehuai. The common conception of the war is of the Nationalists fighting in set-piece field battles while the Communists specialised in guerrilla operations, but this in fact was not the whole truth. Mao's military thought was explicitly Clausewitzian,^A and he took to heart Clausewitz's maxim that the accumulation of indirect damage through attrition and guerrilla fighting is insufficient to actually defeat an enemy – a state must also have the ability to challenge that enemy force head-on and fight it to effective annihilation once it has been whittled down. During the war, while the Communists largely avoided direct confrontation (the exploits of the famed Eighth Route Army, for example, were mostly confined to the establishment and operation of irregular forces in Japanese and collaborator-held territory), there was a major conventional confrontation in the form of the Hundred Regiments Offensive of 1940, in which Communist forces overran a large amount of key infrastructure on the Japanese-held northeast coast, including the major coal mines at Jingxing. That this was the only major conventional confrontation doesn't mean, however, that the Communists were not continuing to develop their conventional doctrine, and the renewed Civil War of 1945-9 was fought entirely as a conventional war, with the People's Liberation Army engaging the Nationalists head-on in full-scale battles in the field, rather than chiefly as guerrillas harassing their lines of communication. As such, the People's Volunteer Army that fought in Korea under Peng Dehuai was hardly unprepared for large-scale conventional warfare.
Crucially, particularly at the leadership level, there was also the recognition that a nascent revolutionary government was inherently at threat from powerful neighbours, potently expressed by the historian Guo Moruo in In Commemoration of the 300th Anniversary of 1644, who almost certainly intended the fall of the Ming in 1644 as an allegory for his own times. The decadent Ming were a stand-in for the Nationalists, Li Zicheng's peasant uprising for the Communists, Wu Sangui, the Ming general who defected to the Manchus, was clearly Wang Jingwei; and the oncoming Manchu hordes stood in for the Japanese. Carried in 1644 was the subtle message that while the Communists may win the internal struggle with Chiang (then abated temporarily by the common threat of Japan), they must always keep an eye out for foreign threats massing on their borders, ready to take advantage of their situation while it remained unstable. In the end, Guo was slightly off in making Japan his Manchus, but in the political climate of the post-Civil War era, the United States were just as effective a stand-in. And this attitude filtered down: massive propaganda campaigns emphasised the importance of supporting the Communist war effort in Korea, and by being willing to nip outside aggression (from the Americans) in the bud in a way that the Nationalists had failed to to against the Japanese, the Communists further consolidated their general support. For the People's Republic, the fight for Korea was the existential struggle for Communist China, and unlike the peasant rebels of 1644, they were not planning on losing that fight.
Notes:
Bibliography: