const savedProductSaleslocation = await this.productSaleslocationRepository.save({ ...productSaleslocation, }); 위 코드에서, 아래처럼 코드를 바꿔봤습니다. const savedProductSaleslocation = await this.productSaleslocationRepository.save(productSaleslocation); 정상 작동했는데 차이가 무엇인가요? 또 권장하는 방식은 무엇인가요?
제가 사용중인 우분투 버젼입니다. 몽고 디비 설치를 노션 자료에 있는대로도 설치를 해보고, 삭제하고 공식문서에 있는대로도 설치를 해봤는데 (노션에는 공개키가 server-5.0 으로 되어있고 공식 문서는 server-6.0 으로 되어있더라구요) 설치 후에 실행을 해보면 [fail] 이 뜨면서 실행이 되지 않네요. 구글링해서 여러가지 방법 따라해봐도 계속 fail 이어서 질문글 올립니다. 추가로 이상한 점은 mongod --version 이라고 치면 버전이 나오는게 아니라 Illegal instruction 라고 나옵니다. ++구글에 mongod --version Illegal instruction 라는 키워드로 검색을 해서 https://info-orgs.blogspot.com/2021/10/how-to-install-mongodb-v44-mongodb.html 이 글을 보고 몽고 디비 4.4 버전을 설치해봤는데 mongod --version 이라고 치면 이제 버전이 나오긴 하는데 여전히 실행은 실패하네요. $ service mongod start * Starting database mongod /etc/init.d/mongod: 136: ulimit: error setting limit (Operation not permitted) /etc/init.d/mongod: 142: ulimit: error setting limit (Operation not permitted) start-stop-daemon: start-stop-daemon: unable to open pidfile '/var/run/mongod.pid' for writingunable to set gid to 121 (Permission denied) (Operation not permitted) start-stop-daemon: child returned error exit status 2
네트워크 소스 확인해보니, 같은 강의에서 수행된 Swagger에서 사용한 Header(Authorization)이 살아있고 이를 이용해 로그인 시도하는 것을 확인했습니다. swagger 로그인을 수행하신 분들은 기존 쿠키 삭제하고 다시 시도하시면 정상 로그인 됩니다. 안녕하세요 고양이 프로젝트 로그인 API 연결이 잘 안되어 질문드립니다. 포스트맨에서는 로그인이 정상적으로 수행됩니다. 그런데 프론트에서 로그인을 수행하면 다음과 같이 Unauthorized 에러가 발생합니다. 비밀번호를 다르게 입력해보니 이메일과 비밀번호를 확인하라는 에러가 뜨는걸로 봐서 뭔가 다른 문제가 있는것 같습니다. 아마 프론트 문제인것같은데 어떻게 해결해야할지 모르겠습니다... 도움주시면 감사하겠습니다.
윈도우 환경에서 yarn 이 에러가 나서 npm으로 진행중입니다~ "npm yarn 은 성능만 차이가 나고 명령어는 똑같다" 라고 알고 있는데, 명령어도 다른건가 라는 의문이 들어 질문 드립니다. npm의 경우는 pakage.js 에 아래와 같이 작성 후 npm aaa 로는 실행이 안되고, npm run aaa 로 만 실행이 되는데, yarn aaa 는 실행이 잘 되는듯 하네요 왜 그런 걸까요? run 이 생략된 걸까요? 웹펙 쪽을 먼저 학습하고 가야 할지... 수업 들으면서 모르는걸 다 질문드려도 될까요? package.json script:{ "aaa":"nodemon app.js" }
안녕하세요 선생님 퍼샤드 패턴에서 58분쯤 보면 yarn init이라고 입력을 하시던데 저의 경우에는 에러가 뜹니다. ERROR: init is not COMMAND nor fully qualified CLASSNAME. Usage: yarn [OPTIONS] SUBCOMMAND [SUBCOMMAND OPTIONS] or yarn [OPTIONS] CLASSNAME [CLASSNAME OPTIONS] 왜 입력 값이 충족되지 않았다고 하는 걸까요? 참고로 제 node.js 버전은 18대입니다. 혹시몰라 전체적인 에러메세지 같이 첨부합니다! (base) ➜ 01-05-token-count-api-facade-import git:(master) ✗ yarn init ERROR: init is not COMMAND nor fully qualified CLASSNAME. Usage: yarn [OPTIONS] SUBCOMMAND [SUBCOMMAND OPTIONS] or yarn [OPTIONS] CLASSNAME [CLASSNAME OPTIONS] where CLASSNAME is a user-provided Java class OPTIONS is none or any of: --buildpaths attempt to add class files from build tree --config dir Hadoop config directory --daemon (start|status|stop) operate on a daemon --debug turn on shell script debug mode --help usage information --hostnames list[,of,host,names] hosts to use in worker mode --hosts filename list of hosts to use in worker mode --loglevel level set the log4j level for this command --workers turn on worker mode SUBCOMMAND is one of: Admin Commands: daemonlog get/set the log level for each daemon node prints node report(s) rmadmin admin tools scmadmin SharedCacheManager admin tools Client Commands: applicationattempt prints applicationattempt(s) report app|application prints application(s) report/kill application/manage long running application classpath prints the class path needed to get the hadoop jar and the required libraries cluster prints cluster information container prints container(s) report envvars display computed Hadoop environment variables fs2cs converts Fair Scheduler configuration to Capacity Scheduler (EXPERIMENTAL) jar <jar> run a jar file logs dump container logs nodeattributes node attributes cli client queue prints queue information schedulerconf Updates scheduler configuration timelinereader run the timeline reader server top view cluster information version print the version Daemon Commands: nodemanager run a nodemanager on each worker proxyserver run the web app proxy server registrydns run the registry DNS server resourcemanager run the ResourceManager router run the Router daemon sharedcachemanager run the SharedCacheManager daemon timelineserver run the timeline server SUBCOMMAND may print help when invoked w/o parameters or with -h. 구글링은 해봐도 못찾겠고, 그나마 힌트가 될만한건 이전에 hadoop 설치하면서 yarn이 같이 깔렸던 것 같은데, 그것과 충돌이 되서 그럴 수 있다는 정보까진 찾았습니다! brew uninstall hadoop 으로 하둡을 날려버렸더니 yarn 명령이 아예 작동이 안되는 것으로 봐서는 맞는 것 같습니다. brew install yarn으로 설치 다시 해줬더니 작동은 잘 됩니다! 선생님 이럴경우에 삭제 말고 따로 하둡과 충돌할 경우에 hadoop의 yarn과 node.js의 yarn을 별도로 관리하는 방법은 없을까요?
KT망을 사용 중일 경우 ts-jest가 설치되지 않는 문제가 있습니다. 해당 문제는 npm의 registry를 미러 서버로 설정한 뒤 nest new~ 를 통해 프로젝트를 생성하고, 다시 원 서버로 복구하시면 됩니다. npm config set registry https://registry.npmjs.cf/ nest new project npm config set registry https://registry.npmjs.org/ 안녕하세요 4번째 섹션의 첫 강의 NestJS 개발 환경 셋팅 을 보고 NestJS를 통한 Project를 생성하려 합니다. 사용중인 컴퓨터 환경은 다음과 같습니다. Apple Silicon M1 Max MacOS Ventura 13.2 Node: 16.16.0 Npm: 8.11.0 그런데 nest 문서에 나와있는 방법대로 프로젝트를 생성하면 에러가 발생합니다. > nest new project ⚡ We will scaffold your app in a few seconds.. ? Which package manager would you ❤️ to use? npm CREATE project/.eslintrc.js (663 bytes) CREATE project/.prettierrc (51 bytes) CREATE project/README.md (3340 bytes) CREATE project/nest-cli.json (171 bytes) CREATE project/package.json (1938 bytes) CREATE project/tsconfig.build.json (97 bytes) CREATE project/tsconfig.json (546 bytes) CREATE project/src/app.controller.spec.ts (617 bytes) CREATE project/src/app.controller.ts (274 bytes) CREATE project/src/app.module.ts (249 bytes) CREATE project/src/app.service.ts (142 bytes) CREATE project/src/main.ts (208 bytes) CREATE project/test/app.e2e-spec.ts (630 bytes) CREATE project/test/jest-e2e.json (183 bytes) ▹▹▹▹▸ Installation in progress... ☕ Failed to execute command: npm install --silent ✖ Installation in progress... ☕ 🙀 Packages installation failed! In case you don't see any errors above, consider manually running the failed command npm install to see more details on why it errored out. Thanks for installing Nest 🙏 Please consider donating to our open collective to help us maintain this package. 🍷 Donate: https://opencollective.com/nest 그래서 생성된 project 폴더로 이동하여 npm install --verbose를 통해 어디서 실패하는지 확인해 보았더니 다음과 같은 내용을 얻을 수 있었습니다. 로그가 너무 길어서, Error 부분만 넣겠습니다. npm timing idealTree:node_modules/windows-release/node_modules/execa Completed in 32ms npm http fetch GET 200 https://registry.npmjs.org/end-of-stream 28ms (cache revalidated) npm timing idealTree:node_modules/windows-release/node_modules/get-stream Completed in 28ms npm timing idealTree:node_modules/pump Completed in 1ms npm timing idealTree:node_modules/end-of-stream Completed in 0ms npm timing idealTree:node_modules/windows-release/node_modules/human-signals Completed in 0ms npm timing idealTree:node_modules/send/node_modules/debug/node_modules/ms Completed in 0ms npm timing idealTree:buildDeps Completed in 314816ms npm timing idealTree:fixDepFlags Completed in 3ms npm timing idealTree Completed in 314826ms npm timing command:install Completed in 314831ms npm verb type system npm verb stack FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/ts-jest: aborted npm verb stack at ~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/minipass-fetch/lib/body.js:168:15 npm verb stack at runMicrotasks (<anonymous>) npm verb stack at processTicksAndRejections (node:internal/process/task_queues:96:5) npm verb stack at async RegistryFetcher.packument (~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/pacote/lib/registry.js:99:25) npm verb stack at async RegistryFetcher.manifest (~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/pacote/lib/registry.js:124:23) npm verb stack at async Arborist.[nodeFromEdge] (~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1108:19) npm verb stack at async Arborist.[buildDepStep] (~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:976:11) npm verb stack at async Arborist.buildIdealTree (~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:218:7) npm verb stack at async Promise.all (index 1) npm verb stack at async Arborist.reify (~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:153:5) npm verb cwd ~/Playground/nodejs/inflearn/nestjs/section4/project npm verb Darwin 22.3.0 npm verb node v16.16.0 npm verb npm v8.11.0 npm ERR! code ECONNRESET npm ERR! errno ECONNRESET npm ERR! network Invalid response body while trying to fetch https://registry.npmjs.org/ts-jest: aborted npm ERR! network This is a problem related to network connectivity. npm ERR! network In most cases you are behind a proxy or have bad network settings. npm ERR! network npm ERR! network If you are behind a proxy, please make sure that the npm ERR! network 'proxy' config is set properly. See: 'npm help config' npm verb exit 1 npm timing npm Completed in 314906ms npm verb unfinished npm timer reify 1676004665919 npm verb unfinished npm timer reify:loadTrees 1676004665923 npm verb code 1 npm ERR! A complete log of this run can be found in: npm ERR! ~/.npm/_logs/2023-02-10T04_51_05_846Z-debug-0.log NestJS에서 supertest 설치를 위해 jest 패키지를 설치하는 것 같은데, jest 패키지들이 정상적으로 (로그에 의하면 ts-jest) 설치되지 않습니다. 같은 에러를 겪은적 있으시거나, 해결법 아시는 분 도움 부탁드립니다. 감사합니다.
DB에 Insert 하려고 할 때 TypeOrm에서 Default 값을 넣어주지 않아 에러가 발생했습니다. (CreatedAt, UpdatedAt 컬럼) 그래서 처음에는 Database에서 Table에 Default값을 세팅하고 사용했는데요. 어떤 분이 질문 하신걸 보고 다시 수정해 보는 중입니다. 강의에 있는 소스는 @Column("datetime", { name: "createdAt", default: () => "CURRENT_TIMESTAMP"}) ... 이렇게 적혀있더군요. 근데 Github의 소스에는 @CreateDateColumn() createdAt: Data; 로만 적혀있었습니다. 그리고 @CreatedDateColumn()은 Special Column이라고 아래와 같이 설명이 있던데요. @CreateDateColumn is a special column that is automatically set to the entity's insertion date. You don't need to set this column - it will be automatically set. 저는 이 얘기를 TypeOrm에서 자동으로 입력해 주는 값으로 이해했는데... 막상 해보면 안되더라고요. 그래서... 만약 Github의 소스와 같이 @CreateDateColumn... 으로 사용하려면 Database에서 Default값을 설정해주어야 하는지 (그렇다면 @CreateDateColumn..은 자동 세팅되는 것이 아니겠죠...) 아니면 영상 강의 상처럼... default() => "CURRENT_TIMESTAMPT"... 로 사용해야 할지요 (물론 영상 강의의 소스는 Database에 그렇게 설정되어 있으니 그렇게 나온것이겠지만요..)
현재 강의에 목업으로 된 테스트 코드가 작성되어져 있는걸 봤는데요 실제 DB에다가 테스트를 하려고 이것저것 해봤는데 잘 안되더라구요;; error: Nest can't resolve dependencies of the ~~ 하면서 에러가 나오고 아마 서비스 쪽에 주입된 레파지토리 때문일 것 같은데 목업이 아닌 실제 db에 테스트코드를 돌리기 위해서는 어떤 작업이 필요한 지 질문드립니다.
우선 잘 되는것이 갑자기 안되는데 해결이 안되서 질문을 올립니다. 우선 제가 한 작업은 다음과 같습니다. 7강의 typeorm 커넥션 맺기까지 완료 한 후 nest g res {service name}을 실행하여 테스트 했습니다 폴더가 생기면서 service, module, controller가 생기는것을 확인 한 후 삭제했습니다. 이후 yarn start:dev를 실행하면 아래와 같이 에러가 났습니다. yarn run v1.22.19 warning ..\package.json: No license field $ nest build --webpack --webpackPath webpack-hmr.config.js --watch Info Webpack is building your sources... ERROR in ./src/main.ts:1:29 TS2307: Cannot find module '@nestjs/core' or its corresponding type declarations. > 1 | import { NestFactory } from '@nestjs/core'; | ^^^^^^^^^^^^^^ 2 | import { DocumentBuilder } from '@nestjs/swagger'; 3 | import { SwaggerModule } from '@nestjs/swagger/dist'; 4 | import { AppModule } from './app.module'; webpack 5.75.0 compiled with 1 error in 3426 ms E:\web-message\dist\main.js:1834 /******/ throw e; ^ Error: Cannot find module '@nestjs/core' Require stack: - E:\web-message\dist\main.js at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15) at Module._load (node:internal/modules/cjs/loader:885:27) at Module.require (node:internal/modules/cjs/loader:1105:19) at require (node:internal/modules/cjs/helpers:103:18) at Object.<anonymous> (E:\web-message\dist\main.js:196:18) at __webpack_require__ (E:\web-message\dist\main.js:1831:33) at fn (E:\web-message\dist\main.js:1938:21) at Object.<anonymous> (E:\web-message\dist\main.js:166:16) at __webpack_require__ (E:\web-message\dist\main.js:1831:33) at E:\web-message\dist\main.js:2757:37 { code: 'MODULE_NOT_FOUND', requireStack: [ 'E:\\web-message\\dist\\main.js' ] } Node.js v18.13.0 우선 warning ..\package.json: No license field 이 부분을 해결하기 위해 찾아보니.. package.json의 private: true를 설정해 주라고 했지만, 이미 되어 있기 때문에 해결을 못했습니다. 그 다음 ERROR in ./src/main.ts:1:29 TS2307: Cannot find module '@nestjs/core' or its corresponding type declarations. > 1 | import { NestFactory } from '@nestjs/core'; 이 부분을 해결해 보기 위해 다음과 같은 작업을 했습니다. @nestjs/core의 삭제 및 재설치 node_modules 폴더 삭제 및 재설치 nestjs/core와 swagger의 충돌 문제가 있다는 얘기에 nestjs/core를 9.0.0으로 nestjs/common을 9.0.0으로, nestjs/platform-express를 9.0.0으로 수정하여 재설치 했으나 여전히 동일한 문제 발생 아래는 현재 저의 package.json입니다 { "name": "web-message", "version": "0.0.1", "private": true, "description": "", "author": "", "license": "UNLICENSED", "scripts": { "build": "nest build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "start": "nest start", "start:dev-backup": "nest start --watch", "start:dev": "nest build --webpack --webpackPath webpack-hmr.config.js --watch", "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "test": "jest", "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json" }, "dependencies": { "@nestjs/common": "^9.3.2", "@nestjs/config": "^2.3.0", "@nestjs/core": "^9.3.2", "@nestjs/platform-express": "^9.0.0", "@nestjs/swagger": "^6.1.4", "@nestjs/typeorm": "^9.0.1", "mariadb": "^3.0.2", "reflect-metadata": "^0.1.13", "rxjs": "^7.2.0", "swagger-ui-express": "^4.6.0", "typeorm": "^0.3.11", "typeorm-extension": "^2.4.2" }, "devDependencies": { "@nestjs/cli": "^9.0.0", "@nestjs/schematics": "^9.0.0", "@nestjs/testing": "^9.0.0", "@types/express": "^4.17.13", "@types/jest": "29.2.4", "@types/node": "18.11.18", "@types/supertest": "^2.0.11", "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.0.0", "eslint": "^8.0.1", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "jest": "29.3.1", "prettier": "^2.3.2", "run-script-webpack-plugin": "^0.1.1", "source-map-support": "^0.5.20", "supertest": "^6.1.3", "ts-jest": "29.0.3", "ts-loader": "^9.2.3", "ts-node": "^10.0.0", "tsconfig-paths": "4.1.1", "typeorm-model-generator": "^0.4.6", "typescript": "^4.7.4", "webpack": "^5.75.0", "webpack-cli": "^5.0.1", "webpack-node-externals": "^3.0.0", "webpack-pnp-externals": "^1.1.0" }, "jest": { "moduleFileExtensions": [ "js", "json", "ts" ], "rootDir": "src", "testRegex": ".*\\.spec\\.ts$", "transform": { "^.+\\.(t|j)s$": "ts-jest" }, "collectCoverageFrom": [ "**/*.(t|j)s" ], "coverageDirectory": "../coverage", "testEnvironment": "node" } } 뭔가... 업데이트를 하면서 문제가 생긴것 같아 찾던 중 nestjs@core와 swagger는 상호 작용하는 버전이 있다고 하던데 그것은 nest 9.X 미만에서 그런 것이고 github에 올려주신 package.json에도 9.X이상의 nestjs를 쓰신것으로 확인하여 swagger와의 충돌 문제는 아닌 것으로 생각했습니다. 어떻게 해결하면 좋을까요~? 참 참고로 nestjs : 9.1.8 yarn: 1.22.19 node: 18.13.0 을 사용하고 있습니다.
구현은 끝나서 swagger 만들고 있는데, 계속 swagger가 보내는 json을 못찾는것같습니다. request의 body에도 아무 값이 안나오네요. 도와주세요ㅠㅠ API 코드 app.post("/users", async (req, res) => { const newUser = req.body.newUser; // 여기에서 오류가 납니다. if ((await isAuthPhone(newUser.phone)) === true) { if (checkValidationEmail(newUser.email) === true) { const og = await makeOG(newUser.prefer); console.log(og); const securePersonal = secure(newUser.personal); const user = new UserCollection({ name: newUser.name, email: newUser.email, personal: securePersonal, prefer: newUser.prefer, pwd: newUser.pwd, phone: newUser.phone, og: og, }); await user.save(); await sendWelcomeTemplateToEmail(newUser); console.log( `✅: "${user.name}" 사용자가 신규 가입에 성공했습니다.` ); res.send(user._id); } else { res.status(422).send("NotValidationEmail"); } } else { res.status(422).send("NotAuthPhone"); } }); Swagger 코드 (yaml 파일은 복붙하니까 이상하게 나와서 이미지로 첨부할게요) (+ 이미지에선 parameter의 name이 body로 되어있지만, 위 API 코드에 맞춰서 name을 newUser로 설정했었지만 같은 에러가 떴었습니다.) 에러 메시지 Swagger parameter 화면 아무리 찾아도 방법을 모르겠어서 올립니다ㅠㅠ.... 도와주세요.....