Catalyzes the second step in the formation of the mannose 6-phosphate targeting signal on lysosomal enzyme oligosaccharides by removing GlcNAc residues from GlcNAc-alpha-P-mannose moieties, which are formed in the first step. Also hydrolyzes UDP-GlcNAc, a sugar donor for Golgi N-acetylglucosaminyltransferases.