The fifth-generation (5G) wireless communication is useful for positioning due to its large bandwidth and low cost. However, the presence of obstacles that block the line-of-sight (LOS) path between devices would affect localization accuracy severely. In this paper, we propose an online learning approach to mitigate ranging error directly in non-line-of-sight (NLOS) channels. The distribution of NLOS ranging error is learned from received raw signals, where a network with neural processes regressor (NPR) is utilized to learn the environment and range-related information precisely. The network can be implemented for online learning free from retraining the network, which is computationally efficient. Simulation results show that the proposed approach outperforms conventional techniques in terms of NLOS ranging error mitigation.