.replace('/\s\s+/g', ' ')
Неправильно определяете регулярное выражение - кавычки не нужны.
Нет необходимости дублировать
\s
.
Есть иные способы помимо
replace
избавиться от повторяющихся пробелов.
document.querySelector('#text').addEventListener('input', e => {
const value = e.target.value.trim();
const output = document.querySelector('#output');
output.textContent = value.replace(/\s+/g, ' ').length;
// или
output.innerText = value.split(/\s+/).join(' ').length;
// или
output.innerHTML = ''.concat(...(value.match(/\S+\s?/g) || [])).length;
});