• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

[SOLVED] NestJS 프로젝트 생성 실패

23.02.10 14:15 작성 23.02.10 15:26 수정 조회수 3.79k

0

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) 설치되지 않습니다.

같은 에러를 겪은적 있으시거나, 해결법 아시는 분 도움 부탁드립니다.

감사합니다.

답변 3

·

답변을 작성해보세요.

1

김성준님의 프로필

김성준

2023.02.11

안녕하세요! 저도 같은 문제가 발생해서 위 두개의 블로그를 참고해서 해결했습니다 도움이 되었으면 좋겠습니다~

https://velog.io/@librarian/ts-jest-설치-안되는-현상

https://www.inflearn.com/questions/753777/nest-new-aaa-설치-오류-문제-npx도-안돼요

1

gameone2님의 프로필

gameone2

2023.02.10

저와 같은 원인인지는 모르겠지만 계속 이 문구가 뜨고 프로젝트 생성에 수십번 실패했었습니다.
에러 문구 : Failed to execute command: npm install --silent


yarn으로 해봐도 동일했고, 구글링 해보니 node버전의 문제일수도 있다 하여 node, nest, npm 버전 다 바꿔서도 해보고 처음부터 다시 깔아서도 해보았으나 모두 실패했었구요,,,
그러다 국내에서는 . . . 인터넷 통신망에도 영향을 받는다라고 해서 lg인터넷 통신망에서 했더니 너무 잘 되더라고요,,ㅎ kt통신망 측에서 실패하는 것 같습니다.
물론 이 원인이 아닐 수도 있지만 혹시나 해서 말씀드려봅니다 !

감사합니다.. 해당 내용으로 검색해보니, 미러서버에서는 동작한다는 것을 확인했습니다..ㅠㅠ 제 시간을 살려주셨어요.

gameone2님의 프로필

gameone2

2023.02.10

헉 힌트가 되었다니 너무 기쁘네요 ㅎㅎ !!
이제 즐거운 개발 되시길 바랍니다 ! 주말 잘 보내세욥~!~!

김련호님의 프로필

김련호

2023.02.20

1시간 삽질했네요. 그 이상의 시간을 쓰지 않도록 해주셔서 정말 너무나 감사합니다...KT 너무했어

0

Alternative Way를 통해 깃에서 Nest Project를 내려받아도 결국 동일한 에러가 발생합니다. Resgistry의 문제인것 같아서 npm config set registry http://registry.npmjs.org/ 통해 repository를 설정해도 같은 문제가 발생합니다.