본문 바로가기

node.js/npm(Package Manager)

[NPM] 다른 npm registry에서 npm 모듈 다운로드하기

반응형

저는 회사에서 npm 로컬 저장소를 이용하여 패키지를 업로드하고, 다운로드 받아 사용하고 있습니다.

이를 위해 npm default registry를 설정해두었습니다.

npm config set registry https://registry.xxxxx.com/xxxxx/

 

이 경우 오픈소스 패키지를 npm 명령어로 설치하려 할 경우, 위에서 설정한 default registry에 패키지가 존재하지 않아 404 에러가 발생됩니다.

npm install --save-dev electron
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.xxxxx.com/xxxxx/electron - not_found
npm ERR! 404 
npm ERR! 404  'electron@*' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.


이 경우 npm install 시에 --registry 옵션을 넣어주면 다른 registry에서 패키지 다운로드가 가능합니다.

일반적인 npm 패키지는 --registry https://registry.npmjs.org/ 를 넣어주면 됩니다.

npm install --save-dev electron --registry https://registry.npmjs.org/
added 91 packages, and audited 92 packages in 15s

10 packages are looking for funding
  run `npm fund` for details

3 moderate severity vulnerabilities

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
반응형