무료
다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 해결됨따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
vscode source control 무한 로딩
git add . git commit git push도 다 되는데요, vscode에 source control 부분에 숫자가 아닌 시간 아이콘만 있고 클릭해보면 상단에 로딩 중에 계속 돌아가고 변경내용에 gitignore부분 반영없이 전부 추가 되어있습니다. 근데 푸쉬까지 하면 github에 gitignore부분은 또 빼고 잘 올라가있네요.. 강사님, 이 부분은 어떻게 해결해야하나요??
- 해결됨따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
학습 로드맵 관련 문의
안녕하세요? 실속 있는 기본강의를 만들어주셔서 감사합니다! 본 강의 완강 후 강사님의 학습 로드맵을 살펴보던 중 궁금한 점이 있어서 질문드립니다. 로드맵 상의 모든 프로젝트 강의는 MongoDB 기반으로 진행되는 것으로 알고 있습니다. 그런데 Docker 강의에서는 MySQL을 기반으로 배포 실습을 하는 것으로 구성이 되어있는 것으로 확인했습니다. 강사님의 쇼핑몰 강의(MongoDB 기반)를 기반으로 프로젝트를 만들고, Docker 수업(MySQL 기반)을 듣고 앞의 프로젝트를 배포하려고 합니다. 강사님의 Docker 강의만으로 앞의 프로젝트를 배포할 수 있을까요? 더불어 혹시 MongoDB 기반이 아니라 MySQL 기반으로 Docker 강의를 제작하신 특별한 의도가 있으신지 궁급합니다~ (가령 MySQL 기반으로 학습하면 추후에 MongoDB 기반으로 배포하는 건 더 쉽다던지...)
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
post 전송 에러 질문드립니다
index.js const express = require("express"); //express import const app = express(); const port = 5006; const bodyParser = require("body-parser"); const { User } = require("./models/User"); //applicatioin /x-www-form -url encoded app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); const mongoose = require("mongoose"); mongoose .connect( "mongodb+srv://euan:abcd1234@boilerplate.tywi2.mongodb.net/?retryWrites=true&w=majority", { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false, } ) .then(() => console.log("mongo db is connected..")) .catch((err) => console.log(err)); app.get("/", (req, res) => { res.send("Hello World122!"); }); app.post("/register", (req, res) => { const user = new User(req.body); user.save((err, userInfo) => { if (err) return res.json({ success: false, err }); return res.status(200).json({ success: ture, }); }); }); app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`); }); user.js const mongoose = require("mongoose"); const userSchema = mongoose.Schema({ name: { type: String, maxlength: 500, }, email: { type: String, trim: true, unique: 1, }, password: { type: String, minlength: 5, }, lastname: { type: String, maxlength: 50, }, role: { type: Number, default: 0, }, image: String, token: { type: String, }, tokenExp: { type: Number, }, }); const User = mongoose.model("User", userSchema); module.exports = { User }; ------------------------------------------------------------------ { "success": false, "err": { "driver": true, "name": "MongoError", "index": 0, "code": 11000, "keyPattern": { "email": 1 }, "keyValue": { "email": "maplestory1419@gmail.com" } } } 서버확인하였는데 이런식으로 에러가 나옵니다. name에 에러가 있는것 가은데 혼자힘으로 해결이 힘들어 질문드립니다! 감사합니다! 몽고db연결도 확인하였습니다. 자꾸 질문드려서 죄송하네요 ㅠㅠ console 창에도 에러가 없으니 뭐가문제인지 단서를 찾을수가 없습니다 ㅠㅠ ps강의 정말감사합니다 ㅠ커피라도 대접해드리고싶네용
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
mongoose db 연동시 에러가 발생합니다. ㅜㅜ
안녕하세요. 몽고 DB 접속하려고 시도할 때 이런 error가 뜨는데 어디서 실수한건지 잘 모르겠네요. 확인 한번만 부탁드립니다.
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
unresolved methods
안녕하세요 user.js에서 userSchema.pre userScema.methods var token = jwt.sign(user._id.toHexString(), secretToken) 에서 pre, methods, toHexString() 세 부분에 밑줄이 뜨며 unresolved methods or functions 등 unresolved 라는 에러가 뜹니다. 작동에는 오류가 없지만 왜 뜨는건지 궁금해서 질문드립니다. 웹스톰 사용하고 있고, 위의 사진과 같습니다. 감사합니다!! //user.js const mongoose = require('mongoose'); const bcrypt = require('bcrypt'); const saltRounds = 10; const jwt = require('jsonwebtoken'); const userSchema = new mongoose.Schema({ name: { type: String, maxlength: 50 }, email: { type: String, trim: true, //공백을 제거 unique: 1 //이메일은 하나. 유니크 했으면 좋겠음. }, password: { type: String, minlength:5 }, lastname: { type: String, maxlength: 50 }, role: { type: Number, default: 0 }, image: String, //오브젝트를 사용하지 않고 이렇게 하나로 줘도 된다. token: { type: String //유효성 검사를 위해 }, tokenExp: { type: Number //유효기간. } }) userSchema.pre('save', function(next){ //비밀번호를 암호화 시킨다 //index.js 의 save를 하기 전에, function을 하면서 암호화 시킨다. //이때 salt를 이용해서 비밀번호를 암호화한다. 그 전에 salt를 먼저 생성해야함. //saltround는 salt가 몇글자인지임 //genSalt: salt를 만든다. var user = this; //this는 이때 위의 user 객체를 가리킨다. if(user.isModified('password')){ bcrypt.genSalt(saltRounds, function(err, salt){ if (err) return next(err); bcrypt.hash(user.password, salt, function (err, hash){ //user.password : this, 즉 객체의 password. 암호화 되기 전의 패스워드 //hash : 암호화된 비밀번호 //store hash in your password DB if (err) return next(err) user.password = hash }) }) } else{ next() } next() }) userSchema.methods.comparePassword = function(plainPassword, cb) { //plainpassword와 암호화된 비밀번호가 같은지 확인하기 -> plainpassword를 암호화 해서 암호화한 password와 같은지 확인하기. bcrypt.compare(plainPassword, this.password, function(err, isMatch){ if(err) return cb(err), cb(null, isMatch) }) } userSchema.methods.generateToken = function(cb){ var user = this; //jsonwebtoken을 이용해서 token을 생성하기 var token = jwt.sign(user._id.toHexString(), 'secretToken') user.token = token user.save(function(err, user){ if(err) return cb(err) cb(null, user) }) } const User = mongoose.model('User', userSchema) //스키마를 모델로 감싸준다 module.exports = { User } //다른 파일에서도 쓸 수 있도록 export
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
강의 정말 감사합니다! 질문하나만 부탁드리겠습니다
const express = require("express"); const app = express(); const port = 5003; const bodyParser = require("body-parser"); const { User } = require("./models/User"); //applicatioin /x-www-form -url encoded app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); const mongoose = require("mongoose"); mongoose.connect( "mongodb+srv://euan:abcd1234@boilerplate.tywi2.mongodb.net/<dbname>?retryWrites=true&w=majority", { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false, } ); app.get("/", (req, res) => { res.send("Hello World!"); }); app.post("/register", (req, res) => { const user = new User(req.body); user.save((err, userInfo) => { if (err) return res.josn({ success: false, err }); return res.status(200).json({ success: ture, }); }); }); app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`); });
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
마지막 강의 auth 부분 질문 있습니다
export default function (SpecificComponent,option,adminRoute = null) { function AuthenticationCheck(props) { const dispatch = useDispatch(); useEffect(() => { dispatch(auth()).then(response => { if(!response.payload.isAuth) { if(option) { props.history.push('/login') } } else { if(adminRoute && !response.payload.isAdmin){ props.history.push('/') } else { props.history.push('/') } } }) }, []) return( <SpecificComponent/> ) } return AuthenticationCheck } 요즘 웹에 빠져서 프론트랑 백엔드 강의를 보는데 재밌는 강의 올려주셔서 감사합니다 !! 궁금한 건 예를들어서 로그인이 필요한 페이지에 로그인 없이 접근한다해도 결국 마지막엔 <SpecificComponent/> 이걸 리턴시켜줘서 렌더링이 될거라고 생각을 했는데요 그런데 useEffect라는 함수를 찾아보면 렌더링이 될 때 특정 작업을 수행해주는 함수라고 했고 느리게 잘 보면 로그인이 필요한 페이지에 로그인 없이 접근할 때 한 0.2초 정도는 잠깐 페이지가 뜨지만 바로 사이트 접근이 안되더라구요 그래서 useEffect 함수를 사용해서 return을 통해 랜더링을 하고 인증 확인 절차가 가능한 부분이구나 했는데 위에 있는 코드에서 useEffect 함수를 안쓰고 해도 로그인이 필요한 페이지에 로그인 없이 접근이 안되는 건 같아서요 그럼 결국 if문에 있는 props.history.push 코드가 실행이 되면 밑에 return <SpecificComponent/> 까지 코드가 진행이 안되고 바로 넘어가는거라고 이해해야하나요??? 제가 아직 자바스크립트에 대한 이해가 부족해서 이상한 질문일수도 있지만 궁금해서 질문해봅니다 감사합니다!!
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
register 에러입니다.
안녕하세요. 강의 잘 보고 있습니다. postman send 시 계속 false가 나오는데, err 메세지를 구체적으로 보려면 어떻게 디버깅해야하는 건가요? index.js 파일 첨부합니다. const express = require('express') const app = express() const port = 5000 const bodyParser = require('body-parser'); const {User} = require("./models/User"); const config = require("./config/key"); //application/x-www-form-urlencoded app.use(bodyParser.urlencoded({extended:true})); //application/json 타입을 분석해서 가져올 수 있게 해준 거 app.use(bodyParser.json()); const mongoose = require('mongoose'); mongoose.connect(config.mongoURI,{ useNewUrlParser: true, useUnifiedTopology:true, useCreateIndex:true, useFindAndModify:false }).then(()=> console.log('MongoDB Connected')) .catch(err => console.log(err)) app.get('/', (req, res) => { res.send('Hello World!') }) //register 라우터 //body-parser을 통해서 클라이언트 > 서버 로 넘어오는 데이터를 받을 수 있다. npm install body-parser --save app.post('/register',(req,res)=> { //회원 가입할때 필요한 정보들을 client에서 가져오면 그것들을 데이터베이스에 넣어준다. const user = new User(req.body) user.save((err,userInfo)=>{ if(err)return res.json({success:false,err}) return res.status(200).json({ success:true }) }) }) app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`) }) user.js 파일 첨부합니다. const mongoose = require('mongoose'); const bcrypt = require('bcrypt'); const { logger } = require('..'); const saltRounds = 10; const userSchema = mongoose.Schema({ name : { type : String, maxlength:50 }, email:{ type:String, trim:true, unique:1 }, password:{ type:String, minlength:5 }, role:{ type:Number, default:0 }, image:String, token:{ type:String }, tokenExp:{ type:Number } }) userSchema.pre('save',function(next){ var use = this; if(user.isModified('password')){ //비밀번호를 암호화 시킨다. bcrypt.genSalt(saltRounds,function (err,salt) { if(err) return next(err) logger.info('ddddd'); bcrypt.hash(user.password,salt,function(err,hash){ if(err) return next(err) user.password = hash next() }) }) } else { next() } }) //스키마를 모델로 감싼다 const User = mongoose.model('User',userSchema) //다른파일에서도 이 모델을 사용할 수 있도록 module.exports = {User} 서버 켜져있습니다. index.js에 console.log(req.body)했을 시 postman 입력값 전송됨을 확인하였습니다. 포스트맨 결과입니다. 조언 부탁드립니다.
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
npm start error
코딩을 이렇게하고 터미널에러는 eferenceError: ture is not defined at Object.<anonymous> (C:\Users\이범진\Documents\boilerplate\index.js:10:24) at Module._compile (internal/modules/cjs/loader.js:1133:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10) at Module.load (internal/modules/cjs/loader.js:977:32) at Function.Module._load (internal/modules/cjs/loader.js:877:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) at internal/main/run_main_module.js:18:47 이렇게 나옵니다. 윈도우 쓰고있는데 mongoose ,node 전부 꼼꼼히 체크하면서 설치했는데 나와서 질문드립니다! 좋은강의 감사합니다! **usercreateindex에서 usecreate index로 변경했는데 똑같은 에러가 나옵니다
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
login 에러
강의 내용 그대로 따라 치고, 포스트맨에서 로그인 시도하였는데 이런 메시지가 나오고, visual studio code로 가보니 터미널에 events.js:291 throw er; // Unhandled 'error' event ^ TypeError: user.comparePassword is not a function at C:\Users\Gyu\NODE JS\boiler-plate\index.js:54:10 at C:\Users\Gyu\NODE JS\boiler-plate\node_modules\mongoose\lib\model.js:4824:16 at C:\Users\Gyu\NODE JS\boiler-plate\node_modules\mongoose\lib\model.js:4824:16 at C:\Users\Gyu\NODE JS\boiler-plate\node_modules\mongoose\lib\helpers\promiseOrCallback.js:24:16 at C:\Users\Gyu\NODE JS\boiler-plate\node_modules\mongoose\lib\model.js:4847:21 at C:\Users\Gyu\NODE JS\boiler-plate\node_modules\mongoose\lib\query.js:4390:11 at C:\Users\Gyu\NODE JS\boiler-plate\node_modules\kareem\index.js:135:16 at processTicksAndRejections (internal/process/task_queues.js:75:11) Emitted 'error' event on Function instance at: at C:\Users\Gyu\NODE JS\boiler-plate\node_modules\mongoose\lib\model.js:4826:13 at C:\Users\Gyu\NODE JS\boiler-plate\node_modules\mongoose\lib\helpers\promiseOrCallback.js:24:16 [... lines matching original stack trace ...] at processTicksAndRejections (internal/process/task_queues.js:75:11) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! boiler-plate@1.0.0 start: `node index.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the boiler-plate@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Gyu\AppData\Roaming\npm-cache\_logs\2020-08-18T12_57_02_736Z-debug.log 이런 오류메시지가 나오네요ㅜㅜ 무슨 문제인지 모르겠습니다. https://github.com/gyuuuu/bolier-plate-ko 깃허브 주소입니다.
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
안녕하세요, 질문이 있습니다
마지막 인증체크 부분이 잘 이해가 되지 않아서 질문 글 올립니다. 제가 이해하기로는 'backend 폴더 index.js에서 auth가 실행되는데 이 때 클라이언트의 토큰 값을 통해서 DB에 해당하는 유저가 있는지 확인을 한 이후에, res.state(200)으로 값을 반환을 한다' 이렇게 이해를 했는데요 중간 과정이 잘이해가 되지 않습니다. backend 폴더 index.js의 app.get('/api/users/auth', auth, (req, res) => { ... } 의 auth가 실행될 때 auth.js 파일의 함수 let auth = (req, res, next) => {..} 안에서 req 값이나 토큰 값을 확인을 하고 싶어서 콘솔창으로 출력해보려고 했는데도 아무런 값이 출력이 되지 않아서 왜 그런지 잘 이해가 되지 않고, 아래처럼 req.token = token; req.user = user; req 값이 출력이 되지 않는 상태인데도 위처럼 token 값과 user값이 어떻게 할당이 되는지 잘 이해가 되지 않습니다 ..
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
props.history.push('/') 에서 자꾸 에러가 발생합니다.
https://github.com/overman623/boiler-plate/blob/master/client/src/components/views/LoginPage/LoginPage.js#L29-L37 강의 잘듣고 있습니다. 처음 해보는것이라 따라해보면서 하고있는데, 아무리 따라해도 이 부분이 막히고 있습니다. Uncaught (in promise) TypeError: Cannot read property 'push' of undefined 라는 에러가 나와서 많이 어렵습니다. 도움을 부탁드립니다.
- 따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
nodemon 실행 관련 질문드립니다
삭제된 글입니다
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
bcrypt.compare 함수 부분의 매개변수 콜백함수 isMatch는 boolean으로 반환되는 것이 아닌가요?
userSchema.methods.comparePassword= function(plainPassword, cb){//cb는 (err,isMatch)이다. //plainPassword 유저가 입력한 password //유저가 입력한password를 암호화 하여 암호화되어있는 비밀번호와 비교한다. bcrypt.compare(plainPassword, this.password, function(err, isMatch){//bcrypt의 compare함수를 이용하여 user가 입력한 password와 비교한 후 결과를 isMatch(boolean)에 담아준다. if(err) return cb(err), //err은 err정보를 담고있다 cb(null,isMatch)//isMatch == 'true'or false ?? <==요 부분이 궁금합니다. }) } 따라서 index.js에서 user.comparePassword if문 부분의 조건을 (isMatch === false)로 비교해서 return해야 하는것이 맞지 않는것인지 궁금합니다. if(!isMatch)//여기 이상함 isMatch값은 boolean이와야하는데 왜 널이 아닌지를 비교하는지 이상 return res.json({loginSuccess: false, message:"비밀번호가 틀렸습니다."})
- 해결됨따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
body-parser에 관한 질문
express 4.16버전 부터 body-parser가 지원된다고 하는데 왜 사용 해야하나요?
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
#3 에서 에러가 발생합니다...
byeongukan@anbyeong-ug-ui-MacBookPro boiler-plate % yarn start yarn run v1.22.4 $ node index.js events.js:292 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE: address already in use :::5000 at Server.setupListenHandle [as _listen2] (net.js:1313:16) at listenInCluster (net.js:1361:12) at Server.listen (net.js:1447:7) at Function.listen (/Users/byeongukan/Documents/boiler-plate/node_modules/express/lib/application.js:618:24) at Object.<anonymous> (/Users/byeongukan/Documents/boiler-plate/index.js:23:5) at Module._compile (internal/modules/cjs/loader.js:1137:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) at Module.load (internal/modules/cjs/loader.js:985:32) at Function.Module._load (internal/modules/cjs/loader.js:878:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 Emitted 'error' event on Server instance at: at emitErrorNT (net.js:1340:8) at processTicksAndRejections (internal/process/task_queues.js:84:21) { code: 'EADDRINUSE', errno: 'EADDRINUSE', syscall: 'listen', address: '::', port: 5000 } error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. byeongukan@anbyeong-ug-ui-MacBookPro boiler-plate % 계속 에러가 뜨는데 왜 이런에러가 뜰까요 ㅠㅠ
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
보일러플레이트 강의 잘 들었습니다. (해결 완료)
덕분에 완성해서 깃허브에 커밋하려고 합니다. 그런데 노드 부분은 커밋되는데 리액트 부분은 modified content, untracked content 라는 메세지만 뜨고 git add가 되지를 않습니다. 깃 원격저장소 연결을 해제하고 다시 연결하는 등 몇몇 방법을 썼는데 해결이 되지를 않습니다. 선생님의 다른 강의를 찾아보아도 깃허브에 업로드하는 부분은 나오지 않은 것 같은데 선생님께서는 어떻게 커밋하셨는지 궁금합니다. 선생님은 위의 에러 메세지 안 뜨고 평범한 방법으로 커밋하셔서 성공하셨나요? 답변이 여기에 작성하시기에 길어지실 것 같으면 검색할 키워드라도 알려주시기를 부탁드립니다.
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
postman html 결과오류
안녕하세요 postman 실행 시 자꾸 경로가 안맞다고 뜨는 것 같은데 어떤 부분이 경로가 안맞는지 전혀 감을 못잡겠어서 질문 드립니다 .. ㅜㅜ 결과 창 파일이고요.. cannot post /login 이라고 하면 이제 없다는 뜻 같은데 소스파일에서 app.post("/login", (req, res) 도 해주었는데 왜 안될까요 github로 코드 올렸습니다 ㅜㅜ https://github.com/00-au/nodejs-react-basic-/commit/99c14ea3c558a0e4e174bdde03085d16fe5ff6eb 제발 해결해주세요.. 얼른 리액트 공부하고싶어요ㅜㅜㅜ 계속 오류나는거 수정에 수정만 하다가 이번에는 정말 혼자 수정 못 하겠어서 질문드려요... 뭐가문제일까요?? 경로?? 경로도 맞게 했고 서버도 시작해놨어요....
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
hash된 비밀번호 저장 관련 질문입니다.
안녕하세요 선생님! 양질의 강의 제공해주셔서 감사합니다! console에 찍어본 것 처럼 hash로 잘 변환이 되고, user 또한 제대로 저장된 것 같은데 user.password= hash가 작동을 안하는 것 같습니다 ㅠㅠ database에 plainPassword가 그대로 노출됩니다.. 혹시 무엇이 문제인지 알 수 있을까요?? 감사합니다.
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
postman 오류 질문
안녕하세요 ! 수업 잘 듣고 있습니다 postman 에서 send 하면 오류가 나는데 어디가 잘못된 걸까요? index.js 소스 첨부합니다 ! const express = require('express') const app = express() const port = 5000 const bodyParser = require('body-parser'); const { User } = require("./models/User"); app.use(bodyParser.urlencoded({extended:true})); app.use(bodyParser.json()); const mongoose = require('mongoose') mongoose.connect('mongodb+srv://root:1234@boilerplate.ielul.mongodb.net/<dbname>?retryWrites=true&w=majority',{ useNewUrlParser:true,useUnifiedTopology:true,useCreateIndex:true,useFindAndModify:false }).then(()=>console.log('MongoDB Connected...')) .catch(err=>console.log(err)) app.get('/', (req, res) => { res.send('Hello World!') }) app.post('/register',(req,res)=>{ //회원 가입시 필요한 정보를 클라이언트에서 가져오면 //데이터베이스에 넣는다 const user = new User(req.body) user.save((err,userInfo)=>{ if(err) return res.json({success:false,err}) return res.status(200).json({ success:true }) }) }) app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`) })