Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

419
Vistas
const utf8Encoder = new TextEncoder(); in Node js

I am trying to use mongodb so I install mongoose package

but the problem is when I am writing like this

const express = require("express");
const dotenv = require("dotenv");
const mongoose = require("mongoose"); //getting error here

It showing me error like this

const utf8Encoder = new TextEncoder();
                    ^

ReferenceError: TextEncoder is not defined

If I am commenting mongoose line I don't get any error but I need to use this even i checked my node version its 16.5.0 I tried looking an old post where same error occur but its not understandable to me any help ? old post link enter link description here

how to fix this error

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Open your encoding.js folder in node_modules>whatwg-url>dist

and write this code

"use strict";
var util= require('util');
const utf8Encoder = new util.TextEncoder();
const utf8Decoder = new util.TextDecoder("utf-8", { ignoreBOM: true });

in place of

"use strict";
const utf8Encoder = new TextEncoder();
const utf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true });

all you where missing is this small part by including utils

var util= require('util');
const utf8Encoder = new util.TextEncoder();
const utf8Decoder = new util.TextEncoder("utf-8", { ignoreBOM: true });
about 4 years ago · Juan Pablo Isaza Denunciar

0

Open your encoding.js folder in node_modules

  1. Open the node_modules
  2. Locate the whawg-url folder and open.
  3. Search for dist folder - there, you'd find the encoding.js folder
  4. Open via VS Code or any IDE of your choice.

Replace these line of code

"use strict";
const utf8Encoder = new TextEncoder();
const utf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true });

With this --

"use strict";
var util= require('util');
const utf8Encoder = new util.TextEncoder();
const utf8Decoder = new util.TextDecoder("utf-8", { ignoreBOM: true });

Then you are good to go.

about 4 years ago · Juan Pablo Isaza Denunciar

0

TextEncoder is not defined node error

This seems to be an issue with older node versions. You need to use the latest node. If you are using nvm type

nvm use node

Note: to download latest node with nvm use this command

nvm install --lts
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda