US law protects marks used in commerce. This extends to any mark (name, image, color) used in commerce regardless of registration status. Most companies take the extra step of registering their marks with the US patent office and when issued they get to put the little (R) next to it. Until that happens companies like to point out their marks with a (TM). Either way, a mark is protected by the simple act of using it in commerce.
The goal of marks is to protect consumers. The idea is that you cannot create confusion in the market place or benefit from someone else's work. For example, companies won't let you even say they are a customer because that will create implied association.
US law also requires companies to enforce and protect their marks. You can't be selective in how you allow others to use it. If you ever want to go to court and protect your mark, you will have to show how you have been active to the best of your ability to protect it.
If npm inc. knowingly allowed you to use the npmjs module name