inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

9장 데이테베이스 세팅하기 TypeError: model.initiate is not a function

해결됨

[개정3판] Node.js 교과서 - 기본부터 프로젝트 실습까지

질문이 좀 많습니다. 질문에 비슷한 사례가 있는데 도저히 해결이 안 되어서 다시 여쭤봅니다. 에러 메시지는 다음과 같습니다. C:\developing\zeroCho\nodeJs\nodebird\models>node index.js hashtag.js Hashtag old-index.js undefined C:\developing\zeroCho\nodeJs\nodebird\models\index.js:30 model.initiate(sequelize); ^ TypeError: model.initiate is not a function 코드 본문입니다. const Sequelize = require('sequelize'); const fs = require('fs'); const path = require('path'); const env = process.env.NODE_ENV || 'development'; const config = require('../config/config')[env]; const db = {}; const sequelize = new Sequelize( config.database, config.username, config.password, config, ); db.sequelize = sequelize; const basename = path.basename(__filename); fs .readdirSync(__dirname) // 현재 폴더의 모든 파일을 조회 .filter(file => { // 숨김 파일, index.js, js 확장자가 아닌 파일 필터링 return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js'); }) .forEach(file => { // 해당 파일의 모델 불러와서 init const model = require(path.join(__dirname, file)); console.log(file, model.name); db[model.name] = model; model.initiate(sequelize); // 문제 발생점 }); Object.keys(db).forEach(modelName => { // associate 호출 if (db[modelName].associate) { db[modelName].associate(db); } }); module.exports = db; 콘솔 한번 찍어보고 싶은데 해당 오류 때문에 진도를 못 나가고 있네요. 도대체 뭐가 문제인지 모르겠습니다.

  • node.js
  • mysql
  • mongodb
  • express
Backend Woonie 댓글 2 좋아요 0 조회수 204

VSCode에서 save를 할 때, landingpage의 useEffect가 실행되는 문제에 대하여

미해결

따라하며 배우는 노드, 리액트 시리즈 - 쇼핑몰 사이트 만들기[전체 리뉴얼]

landingpage에서 useEffect로 fetchProducts를 하고 있는데, VSCode development server를 켜놓고 하지 않습니까? 근데 vscode에서 save를 할 때 landingpage의 useEffect가 실행되는데, 이게 원래 이런건가요? useEffect는 컴포넌트가 처음 마운트 될 때만 실행되는 것으로 알고 있는데, 개발모드에서 save할 때는 save할 때마다 실행되나요? 궁금하네요.

  • react
  • redux
  • node.js
  • 웹앱
  • mongodb
문주영 댓글 1 좋아요 0 조회수 198

dispatch(logoutUser()) 실행시 dispatch(authuser())도 함께 실행되는 문제

미해결

따라하며 배우는 노드, 리액트 시리즈 - 쇼핑몰 사이트 만들기[전체 리뉴얼]

dispatch(logoutUser()) 실행시 dispatch(authuser())도 함께 실행되는 문제가 발생하고 있는데 원인을 잘 모르겠습니다.

  • react
  • redux
  • node.js
  • 웹앱
  • mongodb
문주영 댓글 2 좋아요 0 조회수 257

에러서 요렇게만 해보세요

미해결

따라하며 배우는 노드, 리액트 시리즈 - 영화 사이트 만들기

npm -v , node -v 로 버전 확인 후 package.json의 engine에서 node, npm 버전 수정 파이썬을 설치. - 설치시 ADD PATH 인가에 체크 packge.json > dependencies에서 bcrypt 삭제 npm install 설치 후 bcryptjs 추가 설치 npm install bcryptjs --save

  • react
  • node.js
  • 웹앱
  • mongodb
  • express
lanterlt 댓글 1 좋아요 0 조회수 269

antd Menu 질문

미해결

따라하며 배우는 노드, 리액트 시리즈 - 영화 사이트 만들기

안녕하세요 강사님 혹시 메뉴가 한개만 있는데도 불구하고 "..." 이라는 메뉴 아래에 "나의 favorite" 으로 생겼습니다. 굳이 "..." 라는 메뉴 아래에 "나의favorite"이 생기지 않고, "Home" 오른쪽에 "나의 favorite" 을 바로 생성하고 싶은데, 이런경우 어떻게 해결 하면 될까요? [NavBar] [NavBar] [NavBar.js] import React, { useState } from 'react'; import LeftMenu from './Sections/LeftMenu'; import RightMenu from './Sections/RightMenu'; import { Drawer, Button } from 'antd'; import Icon from '@ant-design/icons'; import './Sections/Navbar.css'; function NavBar() { const [visible, setVisible] = useState(false) const showDrawer = () => { setVisible(true) }; const onClose = () => { setVisible(false) }; return ( <nav className="menu" style={{ position: 'fixed', zIndex: 5, width: '100%' }}> <div className="menu__logo"> <a href="/">Logo</a> </div> <div className="menu__container"> <div className="menu_left"> <LeftMenu mode="horizontal" /> </div> <div className="menu_rigth"> <RightMenu mode="horizontal" /> </div> <Button className="menu__mobile-button" type="primary" onClick={showDrawer} > <Icon type="align-right" /> </Button> <Drawer title="Basic Drawer" placement="right" className="menu_drawer" closable={false} onClose={onClose} visible={visible} > <LeftMenu mode="inline" /> <RightMenu mode="inline" /> </Drawer> </div> </nav> ) } export default NavBar [LeftMenu.js] import React from 'react'; import { Menu } from 'antd'; function LeftMenu(props) { return ( <Menu mode={props.mode}> <Menu.Item key="mail"> <a href="/">Home</a> </Menu.Item> <Menu.Item key="favorite"> <a href="/favorite">나의 Favorite</a> </Menu.Item> </Menu> ) } export default LeftMenu

  • react
  • node.js
  • 웹앱
  • mongodb
  • express
iokl3319 댓글 1 좋아요 0 조회수 309

강의에 사용한 js파일들 받을수 있을까요?

해결됨

[개정3판] Node.js 교과서 - 기본부터 프로젝트 실습까지

현재 개정3판 노드 강의를 듣고 있는데 강의에서 사용하시는 js파일들 받을수있을까요? 아니면 이미 올려두신곳이 있다면 알려주세요!

  • node.js
  • mysql
  • mongodb
  • express
  • typescript
  • socket.io
  • jwt
철수 댓글 3 좋아요 0 조회수 191

몽고DB

미해결

MERN STACK 커뮤니티 : 시작부터 배포까지 알려주는 React

몽고db질문입니다. 코드를 따라해보는중 몽고DB에서 데이터부분이 안들어 왔습니다. 어떤부분이 문제인지 궁금합니다.

  • react
  • node.js
  • mongodb
  • express
  • firebase
박성현 Park 댓글 1 좋아요 0 조회수 196

logout할 때, server로 요청을 보내서 authUser middleware를 통과하도록 하는 이유?

미해결

따라하며 배우는 노드, 리액트 시리즈 - 쇼핑몰 사이트 만들기[전체 리뉴얼]

logout할 때, server로 요청을 보내서 authUser middleware를 통과하도록 하는 이유? handleLogout function에서 local storage의 accessToken을 삭제시키고, store의 user 정보만 initial state, 그리고 isAuth 등을 false로 바꾸면 그만일텐데, 왜 server에 요청을 보내는 과정이 필요할까요!?

  • react
  • redux
  • node.js
  • 웹앱
  • mongodb
문주영 댓글 1 좋아요 0 조회수 219

No routes matched location Error Component Stack error 질문입니다.

미해결

MERN STACK 커뮤니티 : 시작부터 배포까지 알려주는 React

질문 있어서 남깁니다. 메인페이지에서 Link를 타고 upload, list 들어가서 화면이 로드 돼야하는데 돼지 않고 하얀바탕으로 돼면서 Error표시 없이 No routes matched location "/list" Error Component Stack가 표시 됍니다. 어떤문제이고 해결 방법이 무엇인지 궁금합니다. Ps. 질문이 이해 안가실것 같아서 스샷 올려놨습니다.

  • react
  • node.js
  • mongodb
  • express
  • firebase
댓글 1 좋아요 0 조회수 640

webkit-text-size-adjust 오류

미해결

따라하며 배우는 노드, 리액트 시리즈 - 쇼핑몰 사이트 만들기[전체 리뉴얼]

왜 이러는지 알 수 있을까요? 찾아봐도 모르겠습니다... '-webkit-text-size-adjust' is not supported by Chrome, Chrome Android, Edge 79+, Firefox, Safari. Add 'text-size-adjust' to support Chrome 54+, Chrome Android 54+, Edge 79+.

  • react
  • redux
  • node.js
  • 웹앱
  • mongodb
Seungjoo Lee 댓글 1 좋아요 0 조회수 355

mysql연동건너뛰기

미해결

[웹 개발 풀스택 코스] Node.js 프로젝트 투입 일주일 전 - 기초에서 실무까지

제가 mysql연동이 잘 되지 않아 건너뛰고 보려고 하는데 express라우터부터 그냥 봐도 크게 영향받지않고 진행할 수 있을까요??

  • node.js
  • mysql
  • mongodb
  • express
  • 웹-크롤링
  • socket.io
영준 댓글 1 좋아요 0 조회수 132

marker 크기 관련 질문

미해결

코로나맵 개발자와 함께하는 지도서비스 만들기 2

안녕하세요. 강의를 듣고 있는 고등학생입니다. 학교 프로젝트로 강의 하천이나 수질을 나타내는 지도 서비스를 만들려고 하는데 강의 길이에 따라 마커의 크기를 바꾸고 강의 수질에 따라 마커의 색을 바꾸고 싶습니다. css 파일 자체에서 index.js에서 선언된 변수에 따라 마커의 크기를 바꿀 수는 없나요??

  • node.js
  • 웹앱
  • mongodb
  • express
  • mongoose
wiyuchan1021 댓글 0 좋아요 0 조회수 139

does not provide an export named 'userReducer'

미해결

따라하며 배우는 노드, 리액트 시리즈 - 쇼핑몰 사이트 만들기[전체 리뉴얼]

does not provide an export named 'userReducer' 라는 에러가 뜹니다. 맞게 작성한거 같은데... 설정을 잘못했을까요?

  • react
  • redux
  • node.js
  • 웹앱
  • mongodb
Seungjoo Lee 댓글 2 좋아요 0 조회수 240

upload.css 관련 질문

미해결

코로나맵 개발자와 함께하는 지도서비스 만들기 2

body { padding: 0px !important; margin: 0px !important; font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; } a { color: #00B7FF; } ul { list-style-type: none; margin: 0px; padding: 0px; overflow: hidden; background: #333; position: fixed; width: 100%; z-index: 1001; } li { float: left; } li a { display: block; color: white; text-decoration: none; text-align: center; padding: 14px 16px; } .active { background-color: #0322AB; } li a:hover:not(.active) { background-color: #111; } .infow .body { position: relative; overflow: hidden; } .info .desc { position: relative; margin: 8px 0 0 90px; height: 75px; display: block; } .map .wrap, .map_wrap * { margin: 0; padding: 0; font-size: 12px; } #menu_wrap { position: absolute; top: 0; left: 0; bottom: 0; width: 200px; margin: 50px 0 30px 10px; padding: 5px; overflow-y: auto; background: rgba(255, 255, 255, 0.7); z-index: 1; font-size: 12px; border-radius: 10px; } #menu_wrap hr { display: block; height: 1px; border: 0; border-top: 2px solid #5f5f5f; margin: 3px 0; } #placesList .item { position: relative; border-bottom: 1px solid #888; overflow: hidden; cursor: pointer; width: 100px; } #placesList .item span { display: block; margin-top: 4px; } #placesList .item .info { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; padding: 20px; } #placesList .item .active .info_title { font-weight: bolder; } 인포윈도우에서 제목에 볼드 처리가 되지 않고, 검색결과 간의 구분이 표시되지 않습니다...

  • node.js
  • 웹앱
  • mongodb
  • express
  • mongoose
wiyuchan1021 댓글 1 좋아요 0 조회수 135

보일러플레이트 코드 오류

미해결

코로나맵 개발자가 알려주는 React + Express로 지도서비스 만들기 (Typescript)

보일러플레이트 코드 수업 자료 관련해서 다운받았는데 빈폴더라고 저번 질문에 문의드렸는데 사용중인 os만 물어보시고 답변이 없으셔서 다시 질문드려요 사용중인 os는 윈도우입니다.

  • react
  • node.js
  • mongodb
  • express
  • typescript
3400jkh 댓글 2 좋아요 0 조회수 243

mongoDB 관련 질문

미해결

코로나맵 개발자와 함께하는 지도서비스 만들기 2

#!/usr/bin/env node /** * Module dependencies. */ var app = require('../app'); var debug = require('debug')('suzil:server'); var http = require('http'); const mongoose = require("mongoose"); const userConfig = require("../config/userConfig.json"); let db = mongoose.connection; db.on("error",console.error); db.once("open",()=>{ console.log("Connected to mongo Server"); }); mongoose.connect( `mongodb+srv://wiyuchan1021:${userConfig.PW}>@suzilo.i1je5.mongodb.net/suzilo?retryWrites=true&w=majority`, {useNewUrlParser: true, useUnifiedTopology: true} ) /** * Get port from environment and store in Express. */ var port = normalizePort(process.env.PORT || '3000'); app.set('port', port); /**f * Create HTTP server. */ var server = http.createServer(app); /** * Listen on provided port, on all network interfaces. */ server.listen(port); server.on('error', onError); server.on('listening', onListening); /** * Normalize a port into a number, string, or false. */ function normalizePort(val) { var port = parseInt(val, 10); if (isNaN(port)) { // named pipe return val; } if (port >= 0) { // port number return port; } return false; } /** * Event listener for HTTP server "error" event. */ function onError(error) { if (error.syscall !== 'listen') { throw error; } var bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port; // handle specific listen errors with friendly messages switch (error.code) { case 'EACCES': console.error(bind + ' requires elevated privileges'); process.exit(1); break; case 'EADDRINUSE': console.error(bind + ' is already in use'); process.exit(1); break; default: throw error; } } /** * Event listener for HTTP server "listening" event. */ function onListening() { var addr = server.address(); var bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port; debug('Listening on ' + bind); } 코드 실행하면 PS C:\Users\yuchan\suzil> npm start > suzil@0.0.0 start > nodemon ./bin/www [nodemon] 3.1.7 [nodemon] to restart at any time, enter rs [nodemon] watching path(s): . [nodemon] watching extensions: js,mjs,cjs,json [nodemon] starting node ./bin/www (node:13580) [MONGODB DRIVER] Warning: useNewUrlParser is a deprecated option: useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version (Use node --trace-warnings ... to show where the warning was created) (node:13580) [MONGODB DRIVER] Warning: useUnifiedTopology is a deprecated option: useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version MongoServerError: bad auth : authentication failed at Connection.sendCommand (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connection.js:289:27) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Connection.command (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connection.js:312:26) at async continueScramConversation (C:\Users\yuchan\node_modules\mongodb\lib\cmap\auth\scram.js:131:15) at async executeScram (C:\Users\yuchan\node_modules\mongodb\lib\cmap\auth\scram.js:80:5) at async ScramSHA1.auth (C:\Users\yuchan\node_modules\mongodb\lib\cmap\auth\scram.js:39:16) at async performInitialHandshake (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connect.js:104:13) at async connect (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connect.js:24:9) { errorResponse: { ok: 0, errmsg: 'bad auth : authentication failed', code: 8000, codeName: 'AtlasError' }, ok: 0, code: 8000, codeName: 'AtlasError', connectionGeneration: 0, [Symbol(errorLabels)]: Set(2) { 'HandshakeError', 'ResetPool' } } node:internal/process/promises:391 triggerUncaughtException(err, true /* fromPromise */); ^ MongoServerError: bad auth : authentication failed at Connection.sendCommand (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connection.js:289:27) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Connection.command (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connection.js:312:26) at async continueScramConversation (C:\Users\yuchan\node_modules\mongodb\lib\cmap\auth\scram.js:131:15) at async executeScram (C:\Users\yuchan\node_modules\mongodb\lib\cmap\auth\scram.js:80:5) at async ScramSHA1.auth (C:\Users\yuchan\node_modules\mongodb\lib\cmap\auth\scram.js:39:16) at async performInitialHandshake (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connect.js:104:13) at async connect (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connect.js:24:9) { errorResponse: { ok: 0, errmsg: 'bad auth : authentication failed', code: 8000, codeName: 'AtlasError' }, ok: 0, code: 8000, codeName: 'AtlasError', connectionGeneration: 0, [Symbol(errorLabels)]: Set(2) { 'HandshakeError', 'ResetPool' } } Node.js v20.17.0 [nodemon] app crashed - waiting for file changes before starting... 이러한 오류가 터미널에 뜨는데 왜 그런걸까요?

  • node.js
  • 웹앱
  • mongodb
  • express
  • mongoose
wiyuchan1021 댓글 1 좋아요 0 조회수 182

mongodb 접속 실패

미해결

사물인터넷 통신은 내 손에 (Arduino, MQTT, Nodejs, MongoDB, Android,VS Code)

Drivers를 선택해서 나온 url주소로도 MongoDB for VS Code를 선택해서 나온 url주소로도 접속이 실패합니다. Node.js 코드는 다음과 같이 작성했습니다. const mongoose = require("mongoose"); const MONGODB_URL = "mongodb+srv://root:1234@education.sidnf.mongodb.net/"; mongoose .connect(MONGODB_URL) .then(() => console.log("Connected to database!")) .catch(() => console.log("Connection failed...")) Connection failed... 라고 나옵니다. Network Access에서도 0.0.0.0으로도 해보고, 제 컴퓨터의 IP주소로도 해보았습니다. 전부 접속 실패가 뜹니다. 이유를 알 수 있을까요?!

  • node.js
  • mongodb
  • arduino
  • iot
  • MQTT
댓글 1 좋아요 0 조회수 349

수업자료 오류

미해결

코로나맵 개발자가 알려주는 React + Express로 지도서비스 만들기 (Typescript)

보일러플레이트 코드 소개에 있는 수업자료를 다운받았는데 압축해제하려고 보니까 해제도 안되고 압축폴더에는 파일이 아무것도 없네요

  • react
  • node.js
  • mongodb
  • express
  • typescript
3400jkh 댓글 1 좋아요 0 조회수 185

빌드 배포

미해결

따라하며 배우는 노드, 리액트 시리즈 - 쇼핑몰 사이트 만들기[전체 리뉴얼]

안녕하세요 강사님 ! 쇼핑몰 만들기 강의 빌드 배포과정에서 헤매는 수강생들이(저 포함) 많은 것 같은데 혹시 빌드 배포과정까지 영상으로 올려주실 계획은 없으실까요??

  • react
  • redux
  • node.js
  • 웹앱
  • mongodb
rang3176 댓글 1 좋아요 0 조회수 161

(3강 1강의) mongoDB 연결 및 데이터베이스 생성이 안 돼요

미해결

Express 튜토리얼 : 웹 서비스를 위한 핵심 API

몽고디비에 회원가입하고, 이제 js코드를 작성해(vscode에서) 몽고디비에서 데이터베이스 및 컬렉션을 생성시키는 과정을 따라가고 있었습니다. 강의 내용과 동일한 구조를 가지고 있고, 코드 작성은 똑같이 index.js에서 진행했습니다. (또 패키지를 확인해본 결과 몽고디비는 잘 설치되어 있었구요) const express = require("express"); const MongoClient = require("mongodb").MongoClient; const app = express(); const port = 5000; const MongoURL= "mongodb+srv://아이디:비밀번호@chaehyun.f26fr.mongodb.net/Express?retryWrites=true&w=majority&appName=Chaehyun"; var db, post; app.use(express.static("public")) app.use(express.urlencoded({extended: false})) //app.set( 'view engine' , 'pug' ) app.set('view engine' , 'ejs' ) app.get("/", (req, res) => { post.insertOne({ 제목 : "test", 내용 : "test", 날짜 : new Date(), }) res.render("index") }); app.post('/calculator', function(req,res){ let result = Number(req.body.num1) + Number(req.body.num2); res.render("result", {result:result}) }) app.all("*", function(req,res){ res.status(404).send("찾을 수 없는 페이지") }) MongoClient.connect(MongoURL, (err, database) => { if(err){ console.log(err); return; } else{ app.listen(port, () => { console.log(`Example app listening on port ${port}`); }); db = database.db("Express"); post = db.collection("posts") } }) 이처럼 입력하였는데 몽고디비에선 데이터베이스와 컬렉션이 생성되지 않습니다... 그런데 수업에선 localhost:5000 을 통해 -> 몽고디비의 데이터베이스 생성을 하시는 듯 해 보였습니다만, 애초에 app.get( )에서의 내용 때문에 웹사이트는 작동되지 않는게 맞지 않나요...?

  • express
  • mongodb
allisha0508 댓글 1 좋아요 0 조회수 129

인기 태그

인프런 TOP Writers

주간 인기글