Homebrew 安装 Node 和 NPM 的问题

Homebrew issues installing Node & NPM

OS - macOS Catalina - 版本 10.15.2

我在 Mac 和我的 Windows 10 机器上使用了 bash shell 并且使用 apt-get 进行了多次安装。最近(可能在更新之后)我注意到当我在 bash 时,我不能再 运行 apt-get 了。

[bash-3.2$ apt-get
bash: apt-get: command not found

这很奇怪,因为我在这台机器上多次使用 apt-get through bash。尝试熟悉 zsh shell,我已经成功安装了 homebrew。

% brew -v
Homebrew 2.2.4
Homebrew/homebrew-core (git revision 57b7f; last commit 2020-01-24)

看起来不错。现在是加载 Node 的时候了(它总是与 npm 一起安装)

% brew install node
Warning: node 13.7.0 is already installed, it's just not linked
You can use 'brew link node' to link this version.

% brew link node
Linking /usr/local/Cellar/node/13.7.0... 
Error: Could not symlink include/node/common.gypi

好的...

% brew link --overwrite node
Linking /usr/local/Cellar/node/13.7.0... 
Error: Could not symlink include/node/common.gypi
/usr/local/include/node is not writable.

所以这就是我尝试从 zsh运行 节点时剩下的东西

% node -v
zsh: command not found: node
% npm -v
env: node: No such file or directory

如果我尝试 运行 在 sudo 中进行 brew,它会阻止 root 访问,明白了。如果我尝试从节点的网站安装节点,我会收到此错误

"node-v12.14.1.pkg” can’t be opened because Apple cannot check it for malicious software.

有没有在 zsh 和 homebrew 方面有更多经验的人知道如何让我进入 zsh 中的节点?[​​=21=]

我真的很喜欢使用像这样的包:npm create-react-app

来自 brew doctor 的更新

来自酿造医生:

Warning: Unbrewed header files were found in /usr/local/include. If you didn't put them there on purpose they could cause problems when building Homebrew formulae, and may need to be deleted. 列出大约 150 个文件,然后

Warning: You have unlinked kegs in your Cellar. Leaving kegs unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. Run 'brew link' on these: node

Warning: Broken symlinks were found. Remove them with 'brew cleanup': i 运行 brew cleanup 但出现错误 Error: Permission denied @ apply2files - /usr/local/lib/node_modules/npm/node_modules/.bin/JSONStream

警告:如果您在 /usr/local 中有任何重要内容,或者如果您不想丢失自制软件中的配置,则此解决方案可能很危险。如果您只是使用 ZSH 并且打算主要使用自制软件作为包管理器,这可能是一个安全的选择。

感谢大家的帮助。这里发生了很多事情,所以对于遇到类似问题的人来说。

  • 卸载自制程序 uninstall homebrew
  • 擦除/usr/local
  • 的全部内容
  • 使用 ruby
  • 安装自制软件

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  • 安装 wget brew install wget
  • 安装节点brew install node
  • 检查 brew 安装 brew doctor

Your system is ready to brew.

  • 检查节点node -v

v13.7.0

  • 检查 npm npm -v

6.13.6

  • 进入节点node
  • 从此过上幸福的生活

我正在做 React 项目,遇到了同样的问题。我通过这种方式解决了不删除自制程序只是删除当前节点并重新安装的问题。


brew install node


它正在与这些孩子一起工作 ;)

node -v

npm -v