The greatest losses Germany of Norway were indeed preventable. Narvik and Blücher could have been prevented.
But that's not the question. I would suggest to read Geirr H Haarr's The German Invasion of Norway. In this he describes the situation 1939/1940 very well.
Norway was pro British but still neutral. Still a first attempt by Visling to convince the Germans to invade failed. Hitler wasn't interested. However, the Altmark incident changed that dramatically. The supply ship, en route home from the Admiral Graf Spee operation, was boarded by HMS Cossack in Norwegian waters in presence of Norwegian torpedo boats. Which didn't interfere. Hitler rightly assumed the Norwegians were unwilling to protect their neutrality. Indeed the Norwegian government tried to avoid interfering with Allied operations at any costs. They were indeed unwilling to act against violations by the British. Hitler also rightly assumed, the seaways to Sweden in winter were no longer secure. Indeed the British had the plan to invade Norway and seize Swedish Kiruna mines.
On April 4 1940 the British started their move on executing Operation Wilfred and Plan R4, the mining of Norwegian waters and the subsequent invasion of Norway, when Germany was starting to react. They indeed executed the mining, but were OTOH surprised by the Germans, who were reacting faster than they expected.
So, yes, the invasion was necessary from a German point of view.
Oh, and losing one carrier, two CL, 9 DD and 6 submarines is not "almost no warship". If the torpedoes had worked better you could add a great chunk of 40 warships attacked by Uboats.