繁体   English   中英

Homebrew 安装 Node 和 NPM 的问题

[英]Homebrew issues installing Node & NPM

操作系统 - 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

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

% 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”,因为 Apple 无法检查它是否存在恶意软件。

在 zsh 和 homebrew 方面有更多经验的人是否知道如何让我进入 zsh 中的节点?

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

来自酿造医生的更新

来自酿造医生:

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': Warning: Broken symlinks were found. Remove them with 'brew cleanup':我运行了 brew cleanup 但出现错误Error: Permission denied @ apply2files - /usr/local/lib/node_modules/npm/node_modules/.bin/JSONStream

我正在研究 React 项目并面临同样的问题。 我通过这种方式解决了不删除自制软件只是删除当前节点并重新安装的问题。


brew install node


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

node -v

npm -v

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

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

  • 卸载自制软件uninstall homebrew
  • 清除 /usr/local 的全部内容
  • 使用红宝石安装自制软件

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

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

Your system is ready to brew.

  • 检查节点node -v

v13.7.0

  • 检查 npm npm -v

6.13.6

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM