• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

npm run start시 new TextEncoder(); 에러 납니다.ㅠㅠ

21.11.17 13:43 작성 조회수 323

0

- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요!
- 먼저 유사한 질문이 있었는지 검색해보세요.
- 서로 예의를 지키며 존중하는 문화를 만들어가요.
- 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.{
  "name": "react",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.1",
    "mongodb": "^4.1.4",
    "body-parser": "^1.19.0",
    "mongoose": "^6.0.13"
  }
}
위에는 package.json이고
index.js에
const mongoose = require('mongoose');
 
넣기만해도 아래와같이 에러납니다. 왜그런걸까요
 

답변 1

답변을 작성해보세요.

0

deok0119님의 프로필

deok0119

2022.03.14

"node_modules/whatwg-url/lib/encoding.js" 파일 열고 아래와 같이 수정해보세요!

 

"use strict";
const {TextDecoder, TextEncoder} = require("util")    //이 부분 추가
const utf8Encoder = new TextEncoder();
const utf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true });

function utf8Encode(string) {
  return utf8Encoder.encode(string);
}

function utf8DecodeWithoutBOM(bytes) {
  return utf8Decoder.decode(bytes);
}

module.exports = {
  utf8Encode,
  utf8DecodeWithoutBOM
};