(dotfiles error) : (erb):32: command not found: npm get prefix

Hello,

All of the installation steps have worked for me besides the last one:

~/.dotfiles/bin/install_dotfiles

I get the following errors:

~ $ ~/.dotfiles/bin/install_dotfiles
(erb):32: command not found: npm get prefix
/Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:74:in `compile_diff': undefined method `write' for File:Class (NoMethodError)
	from /Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:47:in `diff'
	from /Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:51:in `changed?'
	from /Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:1:in `to_proc'
	from /Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:121:in `select'
	from /Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:121:in `main'
	from /Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:161

I’ve read through some other posts on dotfile errors, but haven’t come across any related to undefined methods. Sorry if this has been resolved and I missed it, any help is appreciated!

1 Like

Hello Mike!
Not sure if this would help u, but it’s worth to try.

Look like it fails to install node.

First of all, make sure that you have homebrew on your machine:
run “brew -v”

run “npm config get prefix” , it should give 'usr/local’
and “which npm” , should give a binary script of npm in '/usr/local/bin/npm’
If both of these commands run without any error, check to see if node is already installed in your machine,
simple ‘find -d “/usr/local/lib/node_modules”’, and run “node -v"
If everything runs without giving u an error.
check your bash profile, run “cat ~/.bash_profile” to see whether npm is global.
if path does not have npm, then add npm to your path,
add “export PATH=”$HOME/.npm/bin:$PATH” to your .bash_profile
Now install the dotfiles again.

If it gives the same error, then I would just
reinstall node again by install it with homebrew on the terminal. Also remove the path line from .bash_profile [make sure to save it after]

run “rm -rf /usr/local/lib/node_modules.” to remove node folders
run "brew uninstall node"
run "brew doctor"
run "brew update"
run "brew upgrade"
run "brew cleanup"
run "brew install node"
run “brew postinstall node” <-- if doesn’t work, then run it with sudo

Check whether npm works , run “npm -v”

Let me how it goes for u.

1 Like

Hi Thai,

Thanks for your quick response! I was wrong, it appears some of the requirements were not installed - including brew. I followed your suggestions, but either I did something incorrect or there is another issue (getting closer!).

After promoting my Mac user to Admin, I went back and successfully installed brew:

~ $ brew -v
Homebrew 1.2.1
Homebrew/homebrew-core (git revision 703a; last commit 2017-06-01)

Next, I ran ~/.dotfiles/bin/install_requirements again - and it appeared to work. I used brew to reinstall node, and ran your checks - this is what they return:

~ $ node -v
v0.10.7

~ $ npm config get prefix
npm WARN npm npm does not support Node.js v0.10.7
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm You can find the latest version at https://nodejs.org/
/usr/local

~ $ which npm
/usr/local/bin/npm

find -d “/usr/local/lib/node_modules” returns a long list of filepaths.

Added the path you suggested to my bash profile:

~ $ cat ~/.bash_profile
export PS1="\W $ "
export PATH="$HOME/.npm/bin:$PATH"

After running ~/.dotfiles/bin/install_dotfiles again I get:

~ $ ~/.dotfiles/bin/install_dotfiles
npm WARN npm npm does not support Node.js v0.10.7
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm You can find the latest version at https://nodejs.org/
/Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:74:in `compile_diff': undefined method `write' for File:Class (NoMethodError)
	from /Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:47:in `diff'
	from /Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:51:in `changed?'
	from /Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:1:in `to_proc'
	from /Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:121:in `select'
	from /Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:121:in `main'
	from /Users/mrbrinkman/.dotfiles/bin/.install_dotfiles.rb:161

After checking the Node.js site, it says the latest is v8.0.0 – so I’m confused as to why brew would install something called v0.10.7?

Thanks for taking the time to read this!

Hello Mike,
You’re welcome!

On their site : Here

08 Sep 15 Node v4.0.0 (Current)
09 Jul 15 Node v0.12.7 (Stable)

Look like they jump from v0.1 to v4. I think v.0.10 is outdate.

Back to the problem. I don’t think you’re able to install node js with dotfiles, I couldn’t able to install node with the dotfiles.
I looked up the bash script in the dotfiles folder, here is the ruby and node version they want us to install:

RUBY_VERSION='2.3.1'
NODE_VERSION='6.10.1'

However, I think we can get latest version of ruby and node.
Now, what I know is you have node v.0.10 in your machine, and npm. But can’t “config npm” because it does not support node v 0.10.

Here what I’m thinking to do: remove node v.0.10 and npm, and reinstall them again.
You can solve the problem by following these steps:
First, remove “export PATH=”$HOME/.npm/bin:$PATH" from the .bash_profile file

[it might take a while to install, you can wait, have cup of tea and think about bubble sort :slight_smile: ]

run "rm -rf /usr/local/lib/node_modules."
run "brew uninstall node"
run "brew doctor"
run "brew update"
run "brew upgrade"
run "brew cleanup"
run "brew install node"
run “brew postinstall node”

Run these after to check:
“node -v” --> should be 8.0
"npm -v" --> whatever that is
"npm config get prefix" --> should be /usr/local and no WARN-ing

Also, check rbenv to make sure it’s there
"which rbenv" --> should be /usr/local/bin/rbenv
"rbenv" --> whatever that is

Alright, good luck and let me know what happen :slight_smile:

1 Like

I followed your instructions to remove node and npm, and reinstall them. brew installed v.0.10 again, so I went to the node site and used an installer to get a newer version:

~ $ node -v
v6.10.3
~ $ npm -v
3.10.10

To make sure I have everything, I backtracked some more and re-ran:

git clone https://github.com/appacademy/dotfiles.git .dotfiles

then

~/.dotfiles/bin/install_requirements

There were quite a few errors in the install requirements phase this time – one that stood out is that I have an older version of ruby:

~ $ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0]

It seems this is the default version for Mac, but that’s weird since during the install requirements phase it alerted me that v2.3.1 was already installed. Is my ‘Path’ pointing to the wrong location? I’ve read that the tool rvm could help here - should I use that?

thanks

thanks

This is the portion of the requirements command I mentioned:

Warning: ruby-build-20170523 already installed
install_requirements: Upgrading outdated brew formulae...
Error: git 2.13.0 already installed
Error: heroku 6.6.18 already installed
Error: qt5 5.9.0 already installed
Error: rbenv 1.1.0 already installed
Error: ruby-build 20170523 already installed
install_requirements: Brew formulae installed.
install_requirements: Installing Ruby...
install_requirements: Press enter to continue.

install_requirements: Ruby v2.3.1 already installed.
install_requirements: Ruby v2.3.1 set as default version.

Yes, I actually installed ruby using rvm

I added this line in my bash_profile after:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

let me know what happen after

Inside the dotfiles

   if rbenv global "$RUBY_VERSION" > /dev/null; then
           log "Ruby v$RUBY_VERSION already installed."
   else
    log "activating rbenv..."
    which rbenv || export PATH="$HOME/.rbenv/bin:$PATH"
    eval "$(rbenv init -)" || fail "could not activate rbenv"
    log "Installing Ruby v$RUBY_VERSION..."
    rbenv install "$RUBY_VERSION"
    log "Ruby v$RUBY_VERSION installed."
  fi
  rbenv global "$RUBY_VERSION"
  rbenv rehash
  log "Ruby v$RUBY_VERSION set as default version."

  log "Installing bundler and gems..."
  require_ack

I think Ruby v2.3.1 already set it to global.
But somehow, you can’t run “ruby -v” with v2.3.1 on ur terminal,
may be quit the terminal and run “ruby -v” again.

If you can’t run the newer ruby on your machine, then install ruby manually with rvm.
remove rvm, remove ruby,
install rvm,
install ruby with rvm
and run “ruby -v” again

Thank you so much @thai ! I’ve been struggling to get these dotfiles installed for days! You rock!
@mbrink652 this step through helped me get the current version of ruby: https://stackoverflow.com/questions/29932409/bundle-command-not-found-mac/32190234#32190234
Also, I had a problem before because I wasn’t able to get the most up to date version of Xcode because my OS was too old. You might want to look into that… Anyway, it’s seems like you’re in better hands with thai than myself.

1 Like

Dotfiles successfully installed!

Thank you both for all your help, I believe I have everything in working order! @coreyladovsky that thread did the trick, specifically the part about adding the argument command to .bash_profile so @PATH would point to the correct ruby version:

echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

thanks again to both

3 Likes

@mbrink652 no problem. Glad you’ve got it working now.

1 Like

@mbrink652, @coreyladovsky: You’re welcome! I’m glad you both got it to work. :smile:

2 Likes