Divide a vector by its length to get a unit vector — same direction, length 1. Multiplying a unit vector by any scalar then gives a vector pointing the same way with the desired length. The black vector goes from the origin to the mouse; the red one is its unit-length version drawn at a fixed display scale.
See also: Circumference point — a circumference point is the centre plus a unit vector times the radius.
length = sqrt(v.x * v.x + v.y * v.y)
unit.x = v.x / length
unit.y = v.y / length
const ox = 150, oy = 150
const vx = mouseX - ox
const vy = mouseY - oy
const length = Math.sqrt(vx * vx + vy * vy)
const ux = vx / length
const uy = vy / length