Node installation problems and cannot post-install

Hi, I’m not getting any output issues with brew install node on Mac OS Catalina.

Node is not installing NPM too. I’m getting the following message:

Warning: The post-install step did not complete successfully

You can try again using `brew postinstall node`

But when I try it using brew postinstall node I get the same message again.

after running brew postinstall node -d I get the following output.

Errno::EACCES: Permission denied @ rb_sysopen -

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1386:in `initialize'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1386:in `open'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1386:in `block in copy_file'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1385:in `open'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1385:in `copy_file'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1353:in `copy'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:478:in `block in copy_entry'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1484:in `wrap_traverse'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1487:in `block in wrap_traverse'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1486:in `each'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1486:in `wrap_traverse'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1487:in `block in wrap_traverse'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1486:in `each'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1486:in `wrap_traverse'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1487:in `block in wrap_traverse'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1486:in `each'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1486:in `wrap_traverse'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:475:in `copy_entry'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:453:in `block in cp_r'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1557:in `block in fu_each_src_dest'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1571:in `fu_each_src_dest0'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1555:in `fu_each_src_dest'

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:452:in `cp_r'

/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node.rb:62:in `post_install'

/usr/local/Homebrew/Library/Homebrew/formula.rb:1010:in `block (2 levels) in run_post_install'

/usr/local/Homebrew/Library/Homebrew/formula.rb:865:in `with_logging'

/usr/local/Homebrew/Library/Homebrew/formula.rb:1009:in `block in run_post_install'

/usr/local/Homebrew/Library/Homebrew/utils.rb:478:in `with_env'

/usr/local/Homebrew/Library/Homebrew/formula.rb:999:in `run_post_install'

/usr/local/Homebrew/Library/Homebrew/postinstall.rb:21:in `<main>'

what does ls -al /usr/local say?

I get the following output:

total 0

drwxr-xr-x 16 root wheel 512 29 Jan 08:44 .
drwxr-xr-x@ 11 root wheel 352 8 Oct 19:54 …
-rw-r–r-- 1 root wheel 0 27 Sep 10:12 .com.apple.installer.keep
drwxrwxr-x 3 hefler admin 96 29 Apr 2019 Caskroom
drwxrwxr-x 49 hefler admin 1568 22 Mar 22:01 Cellar
drwxrwxr-x 4 hefler admin 128 22 Mar 19:13 Frameworks
drwxrwxr-x 21 hefler admin 672 22 Mar 20:48 Homebrew
drwxrwxr-x 307 hefler admin 9824 22 Mar 22:47 bin
drwxrwxr-x 11 hefler admin 352 13 Feb 19:13 etc
drwxrwxr-x 73 hefler admin 2336 22 Mar 22:01 include
drwxrwxr-x 127 hefler admin 4064 22 Mar 22:01 lib
drwxr-xr-x 3 root wheel 96 16 Jan 2019 n
drwxrwxr-x 62 hefler admin 1984 22 Mar 22:47 opt
drwxrwxr-x 3 hefler admin 96 22 Oct 17:29 sbin
drwxrwxr-x 28 hefler admin 896 22 Mar 22:47 share
drwxrwxr-x 7 hefler admin 224 29 Apr 2019 var

how about ls -al /usr/local/lib/node_modules? I suspect that’s owned by root.

half is root,

total 24
drwxr-xr-x    9 hefler  admin   288 22 Mar 21:03 .
drwxrwxr-x  127 hefler  admin  4064 22 Mar 22:01 ..
-rw-r--r--@   1 hefler  admin  8196 23 Mar 08:52 .DS_Store
drwxr-xr-x    3 hefler  admin    96 11 Feb  2019 @angular
drwxr-xr-x    9 hefler  admin   288 24 Dec  2018 expo-cli
drwxr-xr-x   11 root    admin   352 12 Feb  2019 gulp-cli
drwxr-xr-x    7 root    admin   224 16 Jan  2019 n
drwxr-xr-x   25 root    admin   800  7 Mar  2019 npm
drwxr-xr-x   12 hefler  admin   384 26 Jan  2019 webpack

Yeah, that should never happen. You can run sudo chown -R $(whoami) /usr/local/* to make sure all homebrew parts are owned by your user (as it should be).

That got it sorted, thank you so much for your help!

Am I right to thing that homebrew somehow installed some packages as root?

No, homebrew doesn’t have that kind of access. Maybe you ran npm with sudo?

Thats a possibility, it was such a long time since I last used node or npm that I can’t remember what I done wrong.