質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

Q&A

解決済

1回答

1106閲覧

capistrano yarn error 原因がわからない

tqkqt0

総合スコア155

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

0グッド

0クリップ

投稿2020/04/07 23:25

EC2デプロイ時にエラーが出ているのですが原因がわかりません。
原因、修正案をご教授頂ければと思います。
よろしくお願い致します。

rails 6.0.2.1
ruby 2.7.0
webpackerでvue.jsを使用

log

100:22 yarn:install 2 01 yarn install --production 3 01 Yarn requires Node.js 4.0 or higher to be installed. 4#<Thread:0x00007ff91ed628c8 /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true): 5Traceback (most recent call last): 6 13: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute' 7 12: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:in `run' 8 11: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:in `instance_exec' 9 10: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/capistrano-yarn-2.0.2/lib/capistrano/tasks/yarn.rake:17:in `block (3 levels) in <top (required)>' 10 9: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:92:in `within' 11 8: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/capistrano-yarn-2.0.2/lib/capistrano/tasks/yarn.rake:18:in `block (4 levels) in <top (required)>' 12 7: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:100:in `with' 13 6: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/capistrano-yarn-2.0.2/lib/capistrano/tasks/yarn.rake:19:in `block (5 levels) in <top (required)>' 14 5: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:80:in `execute' 15 4: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute' 16 3: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in `tap' 17 2: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute' 18 1: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/backends/netssh.rb:170:in `execute_command' 19/Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/command.rb:97:in `exit_status=': yarn exit status: 1 (SSHKit::Command::Failed) 20yarn stdout: Nothing written 21yarn stderr: Yarn requires Node.js 4.0 or higher to be installed. 22 1: from /Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute' 23/Users/ec2/workspace/project/vendor/bundle/ruby/2.7.0/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as ec2@3.12.185.118: yarn exit status: 1 (SSHKit::Runner::ExecuteError) 24yarn stdout: Nothing written 25yarn stderr: Yarn requires Node.js 4.0 or higher to be installed. 26(Backtrace restricted to imported tasks) 27cap aborted! 28SSHKit::Runner::ExecuteError: Exception while executing as ec2@3.12.185.118: yarn exit status: 1 29yarn stdout: Nothing written 30yarn stderr: Yarn requires Node.js 4.0 or higher to be installed. 31 32 33Caused by: 34SSHKit::Command::Failed: yarn exit status: 1 35yarn stdout: Nothing written 36yarn stderr: Yarn requires Node.js 4.0 or higher to be installed. 37 38Tasks: TOP => deploy:updated => yarn:install 39(See full trace by running task with --trace) 40The deploy has failed with an error: Exception while executing as ec2@3.12.185.118: yarn exit status: 1 41yarn stdout: Nothing written 42yarn stderr: Yarn requires Node.js 4.0 or higher to be installed. 43 44 45** DEPLOY FAILED 46** Refer to log/capistrano.log for details. Here are the last 20 lines: 47 48 49 DEBUG [ec20afbb] * rubyzip (2.2.0) 50 51 DEBUG [ec20afbb] * selenium-webdriver (3.142.7) 52 53 DEBUG [ec20afbb] * spring (2.1.0) 54 55 DEBUG [ec20afbb] * spring-watcher-listen (2.0.1) 56 57 DEBUG [ec20afbb] * web-console (4.0.1) 58 59 DEBUG [ec20afbb] * webdrivers (4.2.0) 60 61 DEBUG [ec20afbb] Install missing gems with `bundle install` 62 63 DEBUG [ec20afbb] Finished in 1.133 seconds with exit status 1 (failed). 64 65 INFO [9b459d8c] Running $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/rails/project/shared/bundle --jobs 4 --without development test --deployment --quiet as ec2@3.12.185.118 66 67 DEBUG [9b459d8c] Command: cd /var/www/rails/project/releases/20200407231000 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.7.0" ; $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/rails/project/shared/bundle --jobs 4 --without development test --deployment --quiet ) 68 69 DEBUG [9b459d8c] [DEPRECATED] The `--deployment` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set deployment 'true'`, and stop using this flag 70 71 DEBUG [9b459d8c] [DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set path '/var/www/rails/project/shared/bundle'`, and stop using this flag 72 73 DEBUG [9b459d8c] [DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set without 'development test'`, and stop using this flag 74 75 INFO [9b459d8c] Finished in 0.821 seconds with exit status 0 (successful). 76 77 DEBUG [58a8a91e] Running if test ! -d /var/www/rails/project/releases/20200407231000; then echo "Directory does not exist '/var/www/rails/project/releases/20200407231000'" 1>&2; false; fi as ec2@3.12.185.118 78 79 DEBUG [58a8a91e] Command: if test ! -d /var/www/rails/project/releases/20200407231000; then echo "Directory does not exist '/var/www/rails/project/releases/20200407231000'" 1>&2; false; fi 80 81 DEBUG [58a8a91e] Finished in 0.234 seconds with exit status 0 (successful). 82 83 INFO [c098b029] Running /usr/bin/env yarn install --production as ec2@3.12.185.118 84 85 DEBUG [c098b029] Command: cd /var/www/rails/project/releases/20200407231000 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.7.0" ; /usr/bin/env yarn install --production ) 86 87 DEBUG [c098b029] Yarn requires Node.js 4.0 or higher to be installed. 88 89

サーバー側で直接確認

ec2server

1 2[ec2@ip-10-0-0-210 20200407231000]$ yarn -v 31.22.4 4[ec2@ip-10-0-0-210 20200407231000]$ node -v 5v12.14.0 6[ec2@ip-10-0-0-210 20200407231000]$ 7[ec2@ip-10-0-0-210 20200407230057]$ /usr/bin/env yarn install --production 8yarn install v1.22.4 9[1/4] Resolving packages... 10[2/4] Fetching packages... 11info fsevents@1.2.11: The platform "linux" is incompatible with this module. 12info "fsevents@1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation. 13[3/4] Linking dependencies... 14warning " > vue-eslint-parser@7.0.0" has unmet peer dependency "eslint@>=5.0.0". 15warning " > vue-loader@15.9.1" has unmet peer dependency "css-loader@*". 16warning " > vue-loader@15.9.1" has unmet peer dependency "webpack@^3.0.0 || ^4.1.0 || ^5.0.0-0". 17warning " > webpack-dev-server@3.10.3" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". 18warning "webpack-dev-server > webpack-dev-middleware@3.7.2" has unmet peer dependency "webpack@^4.0.0". 19[4/4] Building fresh packages... 20Done in 10.66s.

capfile

1require 'capistrano/setup' 2require 'capistrano/deploy' 3require 'capistrano/rbenv' 4require 'capistrano/bundler' 5require 'capistrano/yarn' 6require 'capistrano/rails/assets' 7require 'capistrano/rails/migrations' 8 9Dir.glob('lib/capistrano/tasks/*.rb').each { |r| import r }

deproy.rb

1# config valid for current version and patch releases of Capistrano 2lock '~> 3.12.1' 3 4# デプロイするアプリケーション名 5set :application, 'p' 6 7# cloneするgitのレポジトリ 8set :repo_url, 'git@gitlab.com:~~~~~' 9 10# deployするブランチ。デフォルトはmasterなのでなくても可。 11set :branch, 'master' 12 13# deploy先のディレクトリ。 14set :deploy_to, '/var/www/rails/p' 15 16# シンボリックリンクをはるファイル。 17set :linked_files, fetch(:linked_files, []).push('.env', 'config/master.key') 18 19# シンボリックリンクをはるフォルダ。 20set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'node_modules') 21 22# 保持するバージョンの個数(※後述) 23set :keep_releases, 5 24 25# rubyのバージョン 26set :rbenv_ruby, '2.7.0' 27 28#出力するログのレベル。 29set :log_level, :debug 30 31 32namespace :deploy do 33 desc 'Restart application' 34 task :restart do 35 invoke 'unicorn:restart' 36 end 37 38 desc 'Create database' 39 task :db_create do 40 on roles(:db) do |host| 41 with rails_env: fetch(:rails_env) do 42 within current_path do 43 execute :bundle, :exec, :rake, 'db:create' 44 end 45 end 46 end 47 end 48 49 desc 'Run seed' 50 task :seed do 51 on roles(:app) do 52 with rails_env: fetch(:rails_env) do 53 within current_path do 54 execute :bundle, :exec, :rake, 'db:seed' 55 end 56 end 57 end 58 end 59 60 after :publishing, :restart 61 62 after :restart, :clear_cache do 63 on roles(:web), in: :groups, limit: 3, wait: 10 do 64 end 65 end 66end

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

hoshi-takanori

2020/04/08 09:19

Yarn requires Node.js 4.0 or higher to be installed なので node.js を更新しましょう。
tqkqt0

2020/04/08 09:23

ご回答ありがとうございます。 記載にある通り node -v v12.14.0 です。 それでも、更新するべきでしょうか。。
hoshi-takanori

2020/04/08 09:27

あれ、失礼しました。でも、Yarn requires Node.js 4.0 or higher って言ってるので、別の node がいるのでは。node はどうやって入れましたか? また、type -a node の結果を教えてもらえますか?
tqkqt0

2020/04/08 09:33

nodeはyumで入れたと記憶しております。 type -a nodeは home/ec2/.nvm/versions/node/v12.14.0/bin/node です。
hoshi-takanori

2020/04/08 09:51

その node は nvm で入れたっぽいですね。それ以外にも yum で入れたなら、type -a node で /usr/bin/node とかも出てくるはずですけど…。そして、デプロイ時にエラーが出るのは nvm が効いてないからだと思います。
tqkqt0

2020/04/08 09:56

ありがとうございます。 nvmでですか。。 >デプロイ時にエラーが出るのは nvm が効いてないからだと思います。 こちらの原因/解決策はわかりますでしょうか? 重ね重ね申し訳ございません。
guest

回答1

0

自己解決

ありがとうございます。nvm経由のnodeを消しyumで再インストールする事で解決しました!

投稿2020/04/09 01:19

tqkqt0

総合スコア155

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問