执行npm时icu4c报错,使用brew安装旧版本icu4c,icu4c 62.1, 执行node时icu4c报错

当我像往常一样执行npm install的时候,电脑给我了一个重大的打击

➜  RNDemo npm install
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib
  Referenced from: /usr/local/bin/node
  Reason: image not found
[1]    4976 abort      npm install

按照常规操作,我先通过brew查看能不能切换回icu4c 62.1,结果失败了。
查看原因,发现62.1版本已经被删了

➜  RNDemo  brew switch icu4c 62.1
Error: icu4c does not have a version "62.1" in the Cellar.
icu4c installed versions: 63.1
➜  RNDemo brew list icu4c
/usr/local/Cellar/icu4c/63.1/bin/derb
/usr/local/Cellar/icu4c/63.1/bin/genbrk
/usr/local/Cellar/icu4c/63.1/bin/gencfu
/usr/local/Cellar/icu4c/63.1/bin/gencnval
/usr/local/Cellar/icu4c/63.1/bin/gendict
/usr/local/Cellar/icu4c/63.1/bin/genrb
/usr/local/Cellar/icu4c/63.1/bin/icu-config
/usr/local/Cellar/icu4c/63.1/bin/icuinfo
/usr/local/Cellar/icu4c/63.1/bin/makeconv
/usr/local/Cellar/icu4c/63.1/bin/pkgdata
/usr/local/Cellar/icu4c/63.1/bin/uconv
/usr/local/Cellar/icu4c/63.1/include/unicode/ (183 files)
/usr/local/Cellar/icu4c/63.1/lib/libicudata.63.1.dylib
/usr/local/Cellar/icu4c/63.1/lib/libicui18n.63.1.dylib
/usr/local/Cellar/icu4c/63.1/lib/libicuio.63.1.dylib
/usr/local/Cellar/icu4c/63.1/lib/libicutest.63.1.dylib
/usr/local/Cellar/icu4c/63.1/lib/libicutu.63.1.dylib
/usr/local/Cellar/icu4c/63.1/lib/libicuuc.63.1.dylib
/usr/local/Cellar/icu4c/63.1/lib/icu/ (4 files)
/usr/local/Cellar/icu4c/63.1/lib/pkgconfig/ (3 files)
/usr/local/Cellar/icu4c/63.1/lib/ (18 other files)

没办法,重装低版本的icu4c吧:

➜  Desktop cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula

查看git的提交记录

➜  Formula git:(master) git log --follow icu4c.rb
commit e7f0f10dc63b1dc1061d475f1a61d01b70ef2cb7
Author: Mike McQuaid <[email protected]>
Date:   Sun Jan 6 14:57:48 2019 +0000

    icu4c: remove old code.

commit bc0c97952453ff6afc146aa3a706e9902aba4300
Author: BrewTestBot <[email protected]>
Date:   Thu Nov 29 06:17:05 2018 +0000

    icu4c: update 63.1 bottle.

commit 8ce87beeaea9ff3b9b1e811c4087b6a2f0cb0c2c
Author: FX Coudert <[email protected]>
Date:   Wed Nov 28 10:03:16 2018 +0100

    icu4c 63.1

commit 575eb4bbef683551e19f329f60456b13a558132f
Author: Viktor Szakats <[email protected]>
Date:   Tue Oct 9 02:55:55 2018 +0000

    icu4c: secure/fix/follow url(s)

commit c179a064276d698d66953898ff9e02d6e0664b2a
Author: BrewTestBot <[email protected]>
Date:   Wed Aug 15 21:51:09 2018 +0000

    icu4c: update 62.1 bottle.

commit 2235a91cedb2038a7c721796b48e63836c792607
Author: ilovezfs <[email protected]>
Date:   Tue Jul 24 09:44:31 2018 +0200

    icu4c: remove head spec (#30427)

commit e6b65d7433d0a18c36eb584be554500b6ec06884
Author: BrewTestBot <[email protected]>
Date:   Fri Jun 22 02:12:37 2018 +0000

    icu4c: update 62.1 bottle.

commit 004bdfeef173becdc7e1344a4c095945a97ca410
Author: Chongyu Zhu <[email protected]>
Date:   Thu Jun 21 08:27:56 2018 +0800

    icu4c 62.1
    
/////很长,后面的也没意义了

切换到62.1的提交

➜  Formula git:(icu4c-62.1) git checkout -b icu4c-62.1 e6b65d7433d0a18c36eb584be554500b6ec06884
Checking out files: 100% (4667/4667), done.
Switched to a new branch 'icu4c-62.1'

brew重新安装icu4c

➜  Formula git:(icu4c-62.1) brew reinstall ./icu4c.rb
==> Reinstalling icu4c
==> Downloading https://homebrew.bintray.com/bottles/icu4c-62.1.high_sierra.bottle.tar.gz
Already downloaded: /Users/youssef/Library/Caches/Homebrew/downloads/a5c4ecb8f411b03f47332aae44d1a71dddb3a6d7ea70b2d0e2e4b15e41be020d--icu4c-62.1.high_sierra.bottle.tar.gz
==> Pouring icu4c-62.1.high_sierra.bottle.tar.gz
==> Caveats
icu4c is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc

For compilers to find icu4c you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

==> Summary
?  /usr/local/Cellar/icu4c/62.1: 250 files, 67.3MB

然后再使用npm看看,已经可以正常运行了

➜  RNDemo npm install -g npm
⸨░░░░░░░░░░░░░░░░░░⸩ ⠇ loadRequestedDeps: sill install loadAllDepsIntoIdealTree

还有另外一种解决方案,就是更新node版本。首先卸载node和icu4c:

➜  ~ ✗ node -v
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib
  Referenced from: /usr/local/bin/node
  Reason: image not found
[1]    8289 abort      node -v
➜  ~ ✗ brew uninstall node
Uninstalling /usr/local/Cellar/node/10.9.0... (4,022 files, 49.0MB)
➜  ~ ✗ brew install node
==> Downloading https://homebrew.bintray.com/bottles/node-11.14.0.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/a6/a6404eaaa9ad08fe5e224f55ff2062c4bd675d06d8bc6be21d59845a289fca03?__gda__=exp=1555408987~hmac=0112f7625bababfdb3be66f196db2aadbe22b26d4bf5b035278dd766d15014ba&response-content-disposition=
######################################################################## 100.0%
==> Pouring node-11.14.0.mojave.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
?  /usr/local/Cellar/node/11.14.0: 4,502 files, 50.6MB

重新安装icu4c

➜  ~ ✗ node -v
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.63.dylib
  Referenced from: /usr/local/bin/node
  Reason: image not found
[1]    9086 abort      node -v
➜  ~ ✗ brew uninstall icu4c && brew install icu4c
Uninstalling /usr/local/Cellar/icu4c/63.1... (254 files, 68.4MB)
==> Downloading https://homebrew.bintray.com/bottles/icu4c-63.1.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/e7/e707bf5e3d0189ede7d941d95a417b5dacad3eac99b9a677042464140f12fa1d?__gda__=exp=1555409028~hmac=5f29479f55a8d12d8415743ac95fce7f9c4c9370c5a2c38b8ae04222d73a99a5&response-content-disposition=
######################################################################## 100.0%
==> Pouring icu4c-63.1.mojave.bottle.tar.gz
==> Caveats
icu4c is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc

For compilers to find icu4c you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

==> Summary
?  /usr/local/Cellar/icu4c/63.1: 254 files, 68.4MB
➜  ~ ✗ node -v
v11.14.0
➜  ~ ✗ npm update
➜  ~ ✗ npm -v
6.9.0
➜  ~ ✗

发布了249 篇原创文章 · 获赞 926 · 访问量 149万+

猜你喜欢

转载自blog.csdn.net/youshaoduo/article/details/89228454