Cli: [버그]`npm install -g npm`은`npm` λͺ…령을 μ œκ±°ν•©λ‹ˆλ‹€.

에 λ§Œλ“  2019λ…„ 12μ›” 18일  Β·  19μ½”λ©˜νŠΈ  Β·  좜처: npm/cli

뭐? μ™œ

npm λͺ…령은 npm install -g npm μ‹€ν–‰ ν›„ μ œκ±°λ©λ‹ˆλ‹€.

μ–Έμ œ



  • 2019/12/18

  • 이 λͺ…령을 μ‹€ν–‰ν•˜λŠ” 데 μ„±κ³΅ν•œμ‹œκΈ°λ₯Ό μ •ν™•νžˆ κΈ°μ–΅ν•  수 μ—†μ§€λ§Œ 적어도 일주일 μ „μ—λŠ” κΈ°μ–΅ν•  수 μ—†μŠ΅λ‹ˆλ‹€.

μ–΄λ””



  • npm / cli

μ–΄λ–»κ²Œ

ν˜„μž¬ 행동


이것은 λ‘œκ·Έμž…λ‹ˆλ‹€.

~
% brew install node
==> Downloading https://homebrew.bintray.com/bottles/node-13.3.0_1.catalina.bottle.tar.gz
Already downloaded: /Users/manabu/Library/Caches/Homebrew/downloads/8a482358c0487b3ffeeebf4d1f3b3ca825018f6318ecdd6368fd0a6f45e0bea1--node-13.3.0_1.catalina.bottle.tar.gz
==> Pouring node-13.3.0_1.catalina.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
🍺  /usr/local/Cellar/node/13.3.0_1: 4,663 files, 59MB

~
% npm install -g npm
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../../../lib/node_modules/npm/man/man1/npm-access.1
npm ERR! dest /usr/local/share/man/man1/npm-access.1
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../../../lib/node_modules/npm/man/man1/npm-access.1' -> '/usr/local/share/man/man1/npm-access.1'
npm ERR! File exists: /usr/local/share/man/man1/npm-access.1
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/manabu/.npm/_logs/2019-12-18T07_51_00_280Z-debug.log

brew reinstall node μ‹€ν–‰ν–ˆμ„ λ•Œμ΄ λ¬Έμ œκ°€ λ‹€μ‹œ λ°œμƒν–ˆμŒμ„ ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€.

μ‹€μ œλ‘œ 좜λ ₯μ—μ„œ β€‹β€‹λ§ν–ˆλ“―μ΄ --force μ„±κ³΅μ μœΌλ‘œ μ‹€ν–‰ν–ˆμ§€λ§Œ μ΄λŸ¬ν•œ 둜그λ₯Ό ν‘œμ‹œν•˜λŠ” 것이 npm λͺ…령을 μ œκ±°ν•˜λŠ” 것보닀 λ‚«λ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€.

μˆ˜μ • (2020/01/11) :

μ‹€μ œλ‘œ 좜λ ₯μ—μ„œ β€‹β€‹λ§ν–ˆλ“―μ΄ --force μ„±κ³΅μ μœΌλ‘œ μ‹€ν–‰ν–ˆμŠ΅λ‹ˆλ‹€.

더 ꡬ체적으둜 λ‹€μŒ 단계λ₯Ό μˆ˜ν–‰ν–ˆμŠ΅λ‹ˆλ‹€.

  1. npm install -g npm μ˜ν•΄ 제거 된 npm λͺ…λ Ή 볡원

    • Node.js 관리에 Homebrewλ₯Ό μ‚¬μš©ν–ˆκΈ° λ•Œλ¬Έμ— brew reinstall node λ₯Ό μ‹€ν–‰ν•˜μ—¬ λ³΅μ›ν–ˆμŠ΅λ‹ˆλ‹€.

  2. μ–ΈκΈ‰ 된 좜λ ₯으둜 npm install -g --force npm μ‹€ν–‰

μž¬ν˜„ 단계

  • ν•΄λ‹Ή 사항 μ—†μŒ

μ˜ˆμƒλ˜λŠ” λ™μž‘

  • npm μ—…λ°μ΄νŠΈ 성곡

WHO



  • ν•΄λ‹Ή 사항 μ—†μŒ

μ°Έκ³  λ¬Έν—Œ



  • ν•΄λ‹Ή 사항 μ—†μŒ

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

μ†”λ£¨μ…˜μ„ μš”μ•½ν•˜λ©΄ λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

brew reinstall node
npm i -g --force npm

λͺ¨λ“  19 λŒ“κΈ€

에 @isaacs '변화와 κ΄€λ ¨λœ https://github.com/npm/cli/commit/320ac9aeeafd11bb693c53b31148b8d10c4165e8 NPM / 빈 - 링크 # 12 NPM / λΆ€λ“œλŸ¬μš΄-FS # 7 년에 λ°œν‘œ [email protected]

homebrew https://github.com/Homebrew/homebrew-core/commit/6acc21a27d0ba4ecfd6ebf4d77af7025143daefe#diff -d3ef2414308e30df24a517ca9a1324ee @pepyakin @fxcoudert에 μ˜ν•΄ μž‘μ„± / 컀밋 됨 )

AFAICS 이것은 npmμ—μ„œ μ˜λ„ 된 λ™μž‘μž…λ‹ˆλ‹€. 이것이 ν™ˆλΈŒλ₯˜ μ„€μ •μ—μ„œ μ–΄λ–»κ²Œ μ²˜λ¦¬λ˜μ–΄μ•Όν•˜λŠ”μ§€ λΆˆλΆ„λͺ…ν•©λ‹ˆλ‹€.

https://github.com/npm/cli/issues/672

yarn global add npm 을 (λ₯Ό) μ„€μΉ˜ν–ˆκ³  [email protected] μ„€μΉ˜ν–ˆλŠ”λ° 였λ₯˜κ°€ λ°œμƒν•˜μ§€ μ•Šμ•˜μ§€λ§Œ 이제 μ΄μ „μ˜ λͺ¨λ“  κΈ€λ‘œλ²Œ νŒ¨ν‚€μ§€κ°€ μ‚¬λΌμ‘ŒμŠ΅λ‹ˆλ‹€ : ((

λ‚˜λŠ” homebrewμ—μ„œ 옡트 μ•„μ›ƒν•˜κ³  λ‹¨μˆœνžˆ https://github.com/nvm-sh/nvm을 μ‚¬μš©ν–ˆμŠ΅λ‹ˆλ‹€.

κ·Έλƒ₯ ν•΄

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash

그러면 μ–΄λ”˜κ°€μ—

=> Compressing and cleaning up git repository

=> Appending nvm source string to /Users/aprilmintacpineda/.bash_profile
=> Appending bash_completion source string to /Users/aprilmintacpineda/.bash_profile
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

source <name of profile> λ‚΄ 경우 <name of profile> λŠ” ~/.bash_profile μ΄λ―€λ‘œ source ~/.bash_profile

κ·Έλ•Œ

nvm install node λ…Έλ“œμ˜ μ΅œμ‹  버전을 μ„€μΉ˜ν•˜λ©΄ μ΅œμ‹  λ²„μ „μ˜ npm도 μ„€μΉ˜λ˜λ©° μ €μ—κ²Œ νš¨κ³Όμ μ΄μ—ˆμŠ΅λ‹ˆλ‹€.

이 μŠ€λ ˆλ“œμ˜ λͺ¨λ“  μ‚¬λžŒμ—κ²Œ 당신이 λ¬΄μ—‡μ„ν•˜κ³  있고 κ·Έ 이유λ₯Ό μ•Œκ³  μžˆλ‹€λ©΄ 해결책이 λ‹¨μˆœνžˆ

npm i -g --force npm ( --force ν”Œλž˜κ·Έ μ°Έκ³ )

λ¬Έμ œλŠ” npm -I npm을 μˆ˜ν–‰ν•˜κ³  였λ₯˜κ°€ λ°œμƒν•œ ν›„ 'zsh : command not found : npm'으둜 npm λͺ…령을 μ‹œλ„ν•˜λ©΄ μ‹€νŒ¨ν•˜λ―€λ‘œ μ›ν•˜λŠ” κ²½μš°μ—λ„ --force λͺ…령을 μˆ˜ν–‰ ν•  수 μ—†μŠ΅λ‹ˆλ‹€. npm을 λ‹€μ‹œ μ–»κΈ° μœ„ν•΄ λ…Έλ“œλ₯Ό λ‹€μ‹œ μ„€μΉ˜ν•΄μ•Όν–ˆμŠ΅λ‹ˆλ‹€.

μ£„μ†‘ν•©λ‹ˆλ‹€.이 문제λ₯Ό μΌμ‹œμ μœΌλ‘œ ν”Όν•˜λŠ” 방법을 μ™„μ „νžˆ μ„€λͺ…ν•˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€. μ„€λͺ…을 μ—…λ°μ΄νŠΈν–ˆμŠ΅λ‹ˆλ‹€. ν•œ 번 λ΄μ£Όμ„Έμš”.

이 μŠ€λ ˆλ“œμ˜ λͺ¨λ“  μ‚¬λžŒμ—κ²Œ 당신이 λ¬΄μ—‡μ„ν•˜κ³  있고 κ·Έ 이유λ₯Ό μ•Œκ³  μžˆλ‹€λ©΄ 해결책이 λ‹¨μˆœνžˆ

npm i -g --force npm ( --force ν”Œλž˜κ·Έ μ°Έκ³ )

이것은 μ‹€μ œλ‘œ 이것을 κ³ μΉ˜λŠ” μœ μΌν•œ ν•΄κ²°μ±…μ΄μ—ˆμŠ΅λ‹ˆλ‹€.

두 번째둜 이것은 λͺ‡ μ£Ό μ•ˆμ— λ‚˜μ—κ²Œ λ°œμƒν•©λ‹ˆλ‹€. brew reinstall node μˆ˜μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒμ€ npm install -g npm 싀행쀑인 좜λ ₯μž…λ‹ˆλ‹€.

/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../../../lib/node_modules/npm/man/man1/npm-adduser.1
npm ERR! dest /usr/local/share/man/man1/npm-adduser.1
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../../../lib/node_modules/npm/man/man1/npm-adduser.1' -> '/usr/local/share/man/man1/npm-adduser.1'
npm ERR! File exists: /usr/local/share/man/man1/npm-adduser.1
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/albertvilacalvo/.npm/_logs/2020-01-13T11_55_47_922Z-debug.log

μ†”λ£¨μ…˜μ„ μš”μ•½ν•˜λ©΄ λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

brew reinstall node
npm i -g --force npm

이것은 homebrew μ„€μΉ˜μ—μ„œλ§Œ λ°œμƒν•˜λŠ” 것이 μ•„λ‹™λ‹ˆλ‹€. nodejs μ„€μΉ˜ ν”„λ‘œκ·Έλž¨ (곡식 μ‚¬μ΄νŠΈμ—μ„œ)κ³Ό λ™μΌν•œ λ¬Έμ œκ°€ μžˆμŠ΅λ‹ˆλ‹€. κ·Έλž˜λ„ μˆ˜μ •μ€ μž‘λ™ν•©λ‹ˆλ‹€ ... (sudo npm i -g --force npm)

npm을 μ—…λ°μ΄νŠΈν•˜λ©΄ npm이 μ‚­μ œλ©λ‹ˆκΉŒ? 그리고 12 μ›” μ΄ν›„λ‘œ μ •ν•΄μ Έ μžˆμ§€ μ•Šλ‚˜μš”?

npm을 μ—…λ°μ΄νŠΈν•˜λ©΄ npm이 μ‚­μ œλ©λ‹ˆκΉŒ? 그리고 12 μ›” μ΄ν›„λ‘œ μ •ν•΄μ Έ μžˆμ§€ μ•Šλ‚˜μš”?

λ„€, MacOS 10.15.2μ—μ„œλ„ λ‚˜μ—κ²Œ μΌμ–΄λ‚¬μŠ΅λ‹ˆλ‹€.

λ‚˜μ—κ²Œλ„ 일어났닀. MacOS μΉ΄νƒˆλ¦¬λ‚˜ 10.15.3

이것은 μš°λΆ„νˆ¬μ—μ„œ λ‚˜μ—κ²Œ 일어 λ‚¬μœΌλ©° "brew"λ₯Ό μ‚¬μš©ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

κ²°κ΅­ npm을 λ‹€μ‹œ μ„€μΉ˜ν•˜λ €κ³ ν–ˆμ§€λ§Œ sudo μ—†μ΄λŠ” μ„€μΉ˜ν•  수 μ—†μ—ˆμŠ΅λ‹ˆλ‹€. sudo와 ν•¨κ»˜ μ„€μΉ˜ ν•œ λ‹€μŒ ~ / .npm 디렉토리 (및 기타 λͺ‡ 개)의 μ†Œμœ κΆŒμ„ λ˜μ°ΎκΈ°μœ„ν•œ (λͺ…λ°±ν•˜κ²Œ λ‚˜μœ) κ°€μ΄λ“œλ₯Ό μ°Ύμ•˜μŠ΅λ‹ˆλ‹€. μ²˜μŒμ—λŠ” μ—¬μ „νžˆ μž‘λ™ν•˜μ§€ μ•Šμ•˜μ§€λ§Œ hash -r이 문제λ₯Ό ν•΄κ²°ν–ˆμŠ΅λ‹ˆλ‹€ (λŒμ•„ 보면 Ubuntuλ₯Ό λ‹€μ‹œ μ‹œμž‘ν•΄λ„ νš¨κ³Όκ°€μžˆμ„ 수 있음). 이둜 인해 react-snapκ³Ό κ΄€λ ¨λœ λ¬Έμ œλ„ ν•΄κ²° 될 κ°€λŠ₯성이 ν¬λ°•ν•©λ‹ˆλ‹€.

이 λ²„κ·ΈλŠ” 2014 λ…„μ—λ³΄κ³ λ˜μ—ˆκ³  였늘 2020 년에 μ €μ—κ²Œ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. 정말 μž¬μ•™μž…λ‹ˆλ‹€. 이 λ¬Έμ œκ°€ ν•΄κ²° λ κΉŒμš”?

λ‚˜λŠ” homebrewμ—μ„œ 옡트 μ•„μ›ƒν•˜κ³  λ‹¨μˆœνžˆ https://github.com/nvm-sh/nvm을 μ‚¬μš©ν–ˆμŠ΅λ‹ˆλ‹€.

κ·Έλƒ₯ ν•΄

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash

그러면 μ–΄λ”˜κ°€μ—

=> Compressing and cleaning up git repository

=> Appending nvm source string to /Users/aprilmintacpineda/.bash_profile
=> Appending bash_completion source string to /Users/aprilmintacpineda/.bash_profile
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

source <name of profile> λ‚΄ 경우 <name of profile> λŠ” ~/.bash_profile μ΄λ―€λ‘œ source ~/.bash_profile

κ·Έλ•Œ

nvm install node λ…Έλ“œμ˜ μ΅œμ‹  버전을 μ„€μΉ˜ν•˜λ©΄ μ΅œμ‹  λ²„μ „μ˜ npm도 μ„€μΉ˜λ˜λ©° μ €μ—κ²Œ νš¨κ³Όμ μ΄μ—ˆμŠ΅λ‹ˆλ‹€.

nvm을 μ‚¬μš©ν•˜λŠ” 경우 λ°œμƒν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

"nvm을 μ‚¬μš©ν•˜λ©΄ 이런 일이 λ°œμƒν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€."

예, yarn μ‚¬μš©ν•˜λŠ” κ²½μš°μ—λŠ” λ°œμƒν•˜μ§€ μ•Šμ§€λ§Œ 관련성이 μžˆλŠ”μ§€ 잘 λͺ¨λ₯΄κ² μŠ΅λ‹ˆλ‹€.

그건 λ¬΄κ΄€ν•˜λ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€. NVM은 λ…Έλ“œ 버전 κ΄€λ¦¬μžμž…λ‹ˆλ‹€. brewλ₯Ό μ‚¬μš©ν•˜μ—¬ λ…Έλ“œλ₯Ό μ„€μΉ˜ν•  λ•Œ 이것을 κ²½ν—˜ ν•œ λ‹€μŒ nvm으둜 μ „ν™˜ ν•œ ν›„ 아직 κ²½ν—˜ν•˜μ§€ λͺ»ν–ˆμŠ΅λ‹ˆλ‹€. https://github.com/nvm-sh/nvm#installing -and-updating이 무엇인지 λͺ¨λ₯΄λŠ” 경우 μ—¬κΈ°μ—μ„œ ν™•μΈν•˜μ‹­μ‹œμ˜€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰