简体   繁体   中英

react_on_rails install: yarn is required error

I am trying to setup react_on_rails for an existing rails 5.0 app as per the following instructions: https://github.com/shakacode/react_on_rails

  1. gem "react_on_rails", "8.0.0"
  2. rails generate react_on_rails:install

I get the following error:

ERROR: yarn is required. Please install it before continuing. https://yarnpkg.com/en/docs/install

now this is my yarn, npm and node path:

[user@server]$ which node
/usr/bin/node
[user@server]$ which npm
/usr/bin/npm
[user@server]$ which yarn
~/.yarn/bin/yarn

How do i ensure it's using the appropriate yarn and help install react_on_rails?

EDIT: This is my ~/.bashrc file:

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"


export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

export PATH="$PATH:$HOME/.yarn/bin"

This is my /bin/yarn file under my app:

#!/usr/bin/env ruby
VENDOR_PATH = File.expand_path('..', __dir__)
Dir.chdir(VENDOR_PATH) do
  begin
    exec "yarnpkg #{ARGV.join(" ")}"
  rescue Errno::ENOENT
    $stderr.puts "Yarn executable was not detected in the system."
    $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
    exit 1
  end
end

你可以只使用yarn代替yarnpkg

exec "yarn #{ARGV.join(" ")}"

Not sure if one the following fixed it:

unset https_proxy
unset http_proxy

npm config set proxy http://user:****@ip
npm config set https-proxy http://user:***@ip

After that yarn worked.

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