Node.js REPL .load 무한 루프

맛없는콩두유·2023년 3월 27일
0

Node.js REPL에서의 무한 루프로 출력되는 문제

  • index.js
const mongoose = require('mongoose');
mongoose.set('strictQuery',true);

mongoose.connect("mongodb://127.0.0.1:27017/movieApp")
    .then(()=> {
        console.log('connection open')
    })
    .catch(err=> {
        console.log("OH NO ERROR")
        console.log(err)
    })

const movieSchema = new mongoose.Schema({
    title: String,
    year: Number,
    score: Number,
    rating: String
});

const Movie =  mongoose.model('Movie', movieSchema);

const amadeus = new Movie({ title: 'Django', year: 2010, score: 8.0, rating: 'R' });

위 코드에서 .load index.js를 실행하면

무한 루프로 출력되는 문제점이 발생한다.

해결 방안

  • Temianl창과 PowerShell이 아닌 mongoShell을 이용하여 명령어를 입력하니 더 이상 무한 루프가 발생하지 않았다.
Terminal 창 -> mongosh -> .load index.js 

profile
하루하루 기록하기!

0개의 댓글