简体   繁体   中英

Homebrew issues installing Node & NPM

OS - macOS Catalina - Version 10.15.2

I have used the bash shell in Mac and on my Windows 10 machine and have used apt-get for many installs. Recently (possibly after update) I have noticed that when I am in bash, I cannot run apt-get anymore.

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

This is odd because I've used apt-get through bash many many times on this machine. Attempting to familiarize with the zsh shell, I've installed homebrew successfully.

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

Looks good. Now time to load Node (which has always installed npm alongside)

% 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

OK...

% 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.

So here is what I'm left with when I try to run node from zsh

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

If I try to run brew in sudo, it blocks root access, understood. If I try to install node from node's website I get this error

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

Does anyone with more experience in zsh and with homebrew have any idea how to get me into node in zsh?

I've really love to use packages like: npm create-react-app .

UPDATE from brew doctor

from 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. lists about 150 files, then

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': i ran brew cleanup but get an error Error: Permission denied @ apply2files - /usr/local/lib/node_modules/npm/node_modules/.bin/JSONStream

I'm working on the React project and faced the same issue. I solved this way not deleting homebrew just deleting a current node and reinstall.


brew install node


and it's working with these kids;)

node -v

npm -v

WARNING: this solution may be dangerous if you have anything important in /usr/local or if you have configurations in homebrew that you don't want to lose. If you are just using ZSH and are going to be primarily using homebrew as a package manager, this is probably a safe bet.

Thanks everyone for the help. There are many things going on here so for anyone who is having similar issues.

  • uninstall homebrew uninstall homebrew
  • erase the entire contents of /usr/local
  • install homebrew using ruby

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

  • install wget brew install wget
  • install node brew install node
  • check the brew install brew doctor

Your system is ready to brew.

  • check node node -v

v13.7.0

  • check npm npm -v

6.13.6

  • enter node node
  • live happily ever after

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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