gpt4 book ai didi

node.js - Homebrew 安装 Node 和 NPM 时出现问题

转载 作者:太空宇宙 更新时间:2023-11-03 23:12:15 49 4
gpt4 key购买 nike

操作系统 - 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 时剩下的内容

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

如果我尝试在 sudo 中运行brew,它会阻止 root 访问,这是可以理解的。如果我尝试从 Node 的网站安装 Node ,我会收到此错误

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

有没有在 zsh 和 Homebrew 程序方面有更多经验的人知道如何让我进入 zsh 中的 Node ?

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

来自brew doctor的更新

来自 brew doctor :

警告:在/usr/local/include 中发现未编译的头文件。
如果您不是故意将它们放在那里,那么它们可能会导致问题
构建 Homebrew 公式,可能需要删除。
列出大约 150 个文件,然后

警告:您的地窖中有未链接的小桶。
不连接小桶可能会导致构建问题并导致 brew 依赖于
这些小桶一旦建成就无法正常运行。在这些上运行“brew link”:
Node

警告:发现损坏的符号链接(symbolic link)。使用“brew cleanup”删除它们:我运行了 brew cleanup 但出现错误错误:权限被拒绝@apply2files -/usr/local/lib/node_modules/npm/node_modules/.bin/JSONStream

最佳答案

我正在开发 React 项目并遇到了同样的问题。我解决了这种方法,不删除 Homebrew 软件,只是删除当前 Node 并重新安装。


brew 安装 Node


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

Node -v

npm -v

关于node.js - Homebrew 安装 Node 和 NPM 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59897791/

49 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com