Fire officials said up to 16 people remained trapped in a residential building.

Rescuers from around the island were preparing to help, Taiwan's president Tsai Ing-wen said on her Facebook page, promising rapid disaster relief.

The quake hit at 23.50pm around 21km northeast of Hualien, according to the United States Geological Survey.

It follows almost 100 smaller tremors to have hit the area in the last three days and comes exactly two years since a quake of the same magnitude struck the southern Taiwanese city of Tainan, killing more than 100 people.

Most of the death toll from the February 2016 earthquake was from the 16-storey Wei-kuan apartment complex, which toppled on its side with many of its residents buried in the rubble.

It was the only high-rise in Tainan to crumble completely in the quake, which came two days before Lunar New Year, when many people would have been visiting relatives for the biggest celebration of the Chinese calendar.

The safety of the building was called into question immediately after the disaster, when metal cans and foam were found to have been used as fillers in the concrete and residents said there had been cracks in the structure.

Five people were charged over the disaster, including the developer and two architects, with prosecutors saying they "cut corners" that affected the building's structural integrity.

Taiwan lies near the junction of two tectonic plates and is regularly hit by earthquakes.

The island's worst tremor in recent decades was a 7.6 magnitude quake in September 1999 that killed around 2,400 people./.