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

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

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

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Ruby on Rails 5

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

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Q&A

解決済

2回答

4223閲覧

Node.jsを version 0.10.48から4.0以上にしたい[assets:precompile][yarn]

seen

総合スコア49

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Ruby on Rails 5

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

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

0グッド

1クリップ

投稿2018/04/30 13:53

ローカルから本番環境へ移行中の初心者です。
アプリをヘロクへデプロイすると画像が表示されませんでした。
コンパイルが必要だという情報を得て

$ bundle exec rake assets:precompile

とすると

Yarn executable was not detected in the system. Download Yarn at https://yarnpkg.com/en/docs/install

このような表示がでたので

#yarnをインストール $ curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

このようにしてインストールしてバージョンの確認をしてみたところ

$ yarn --version Node version 0.10.48 is not supported, please use Node.js 4.0 or higher.

となりました。yarnのバージョンだっていうのにNodeのバージョンが出てきましてもうこれはわからないと思っているのですが、とりあえずNodeのバージョンを確認すると

$ node -v v0.10.48

と確かに古いようなのでアップデートをと思いましたがやり方がわかりません。
どなたか教えていただけませんでしょうか。
やってみたこと

]$ curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -

許可がないとエラー(下記)

## Installing the NodeSource Node.js 6.x LTS Boron repo... ## Inspecting system... + rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release + uname -m ## Confirming "el6-x86_64" is supported... + curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_6.x/el/6/x86_64/nodesource-release-el6-1.noarch.rpm' ## Downloading release setup RPM... + mktemp + curl -sL -o '/tmp/tmp.Prr8xAUWoD' 'https://rpm.nodesource.com/pub_6.x/el/6/x86_64/nodesource-release-el6-1.noarch.rpm' ## Installing release setup RPM... + rpm -i --nosignature --force '/tmp/tmp.Prr8xAUWoD' エラー: can't create transaction lock on /var/lib/rpm/.rpm.lock (許可がありません) Error executing command, exiting
[vagrant@localhost mymemo]$ npm --version 1.3.6 [vagrant@localhost mymemo]$ nvm --virsion -bash: nvm: コマンドが見つかりません [vagrant@localhost mymemo]$ npm install -g n npm http GET https://registry.npmjs.org/n npm http GET https://registry.npmjs.org/n npm http GET https://registry.npmjs.org/n npm ERR! Error: CERT_UNTRUSTED npm ERR! at SecurePair.<anonymous> (tls.js:1430:32) npm ERR! at SecurePair.emit (events.js:92:17) npm ERR! at SecurePair.maybeInitFinished (tls.js:1029:10) npm ERR! at CleartextStream.read [as _read] (tls.js:521:13) npm ERR! at CleartextStream.Readable.read (_stream_readable.js:341:10) npm ERR! at EncryptedStream.write [as _write] (tls.js:418:25) npm ERR! at doWrite (_stream_writable.js:226:10) npm ERR! at writeOrBuffer (_stream_writable.js:216:5) npm ERR! at EncryptedStream.Writable.write (_stream_writable.js:183:11) npm ERR! at write (_stream_readable.js:602:24) npm ERR! If you need help, you may report this log at: npm ERR! <http://github.com/isaacs/npm/issues> npm ERR! or email it to: npm ERR! <npm-@googlegroups.com> npm ERR! System Linux 2.6.32-696.20.1.el6.x86_64 npm ERR! command "node" "/usr/bin/npm" "install" "-g" "n" npm ERR! cwd /home/vagrant/mymemo npm ERR! node -v v0.10.48 npm ERR! npm -v 1.3.6 npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /home/vagrant/mymemo/npm-debug.log npm ERR! not ok code 0

以上です。 よろしくおねがいします。

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

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

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

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

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

guest

回答2

0

細かい部分に関しては、質問の内容を把握できませんが、
まず、エラーログに残っているnode.jsの基幹アプリケーションに関して述べると、

  • nvm: node.jsのバージョン管理用アプリケーション
  • npm: node.jsのパッケージ管理用アプリケーション
  • yarn: node.jsのパッケージ管理用アプリケーション

この中のyarn がnode.jsのバージョンが低いから動きませんよと言っています。
なので、解決方法としては、node.jsのバージョンを上げてインストールしなおす。
yarnを使うのをやめて、npmを使う。

個人的には、nvmをインストールすることをお勧めします(nvmは、node.jsのバージョンで新しいものが出たら、新しいものに置き換えられるもの。と思ってくれれば、よいと思います。)

出せる回答としては、ひとまず、この辺りでしょうか?
もし、この辺りを調べてみてまだ何かあったら改めて。

追記: Ruby on Railsでは、npmは標準で対応していないとのことなので、node.jsのバージョンを上げるのが無難なようです。

投稿2018/04/30 18:31

編集2018/05/01 01:14
GrayWingAliance

総合スコア218

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

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

maisumakun

2018/05/01 00:40

Railsの場合、WerpackerがYarn前提となっているので、npmに切り替えるのは逆に厄介かと思います。
GrayWingAliance

2018/05/01 01:11

なるほど。それは知らなかったです。修正しておきます。
seen

2018/05/01 11:56

コメントいただきありがとうございます。 nvm、npm、yarnの意味など勉強になりました。ありがとうございます!
guest

0

ベストアンサー

私もハマったことがありますが、そもそもHerokuに画像を保存しておくことはできないようです。
HerokuではなくAmazon S3等のオブジェクトストレージサービスに画像を保存して引っ張ってくる必要があります。

参考
https://blog.goo.ne.jp/moonycat/e/4ef60518690aae69c3f8e8a29c83d3b9
https://teratail.com/questions/78028
http://mutipuro.xyz/rails-heroku-gazou/

投稿2018/04/30 16:27

編集2018/04/30 16:53
退会済みユーザー

退会済みユーザー

総合スコア0

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

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

seen

2018/05/01 11:54

そうなんですか!? 参考サイトありがとうございます。 トライしてみます。
seen

2018/05/01 13:56

参考サイトを元に、3番目のcloudinaryというのを導入しまいたが/app/assets/images 以下の画像が表示されません。コマンドの状況を記載しますので助けていただけると幸いです。 gem追加 bundle install結果 ~略 Fetching aws_cf_signer 0.1.3  Installing aws_cf_signer 0.1.3 Using bcrypt 3.1.11 Using bindex 0.5.0 Using rb-fsevent 0.10.3 Using ffi 1.9.23 Using rb-inotify 0.9.10 Using sass-listen 4.0.0 Using sass 3.5.5 Using bootstrap-sass 3.3.7 Using bundler 1.16.1 Using byebug 10.0.0 Using xpath 3.0.0 Using capybara 2.18.0 Using mime-types-data 3.2016.0521 Using mime-types 3.1 Using carrierwave 1.2.2 Using childprocess 0.8.0 Fetching unf_ext 0.0.7.5 Installing unf_ext 0.0.7.5 with native extensions Fetching unf 0.1.4 Installing unf 0.1.4 Fetching domain_name 0.5.20180417 Installing domain_name 0.5.20180417 Fetching http-cookie 1.0.3 Installing http-cookie 1.0.3 Fetching netrc 0.11.0 Installing netrc 0.11.0 Fetching rest-client 2.0.2 Installing rest-client 2.0.2 Fetching cloudinary 1.9.1 Installing cloudinary 1.9.1 Using coffee-script-source 1.12.2 Using coffee-script 2.4.1 Using method_source 0.9.0 Using thor 0.20.0 Using railties 5.1.5 Using coffee-rails 4.2.2 Using orm_adapter 0.5.0 Using responders 2.4.0 Using warden 1.2.7 Using devise 4.4.3 Using multi_json 1.13.1 Using jbuilder 2.7.0 Using jquery-rails 4.3.1 Using libv8 3.16.14.19 (x86_64-linux) Using ruby_dep 1.5.0 Using listen 3.1.5 Using pg 1.0.0 Using puma 3.11.3 Using sprockets 3.7.1 Using sprockets-rails 3.2.1 Using rails 5.1.5 Using rails_serve_static_assets 0.0.5 Using rails_stdout_logging 0.0.5 Using rails_12factor 0.0.3 Using ref 2.0.0 Using rmagick 2.16.0 Using rubyzip 1.2.1 Using tilt 2.0.8 Using sass-rails 5.0.7 Using selenium-webdriver 3.10.0 Using spring 2.0.2 Using spring-watcher-listen 2.0.1 Using therubyracer 0.12.3 Using turbolinks-source 5.1.0 Using turbolinks 5.1.0 Using uglifier 4.1.6 Using web-console 3.5.1 Bundle complete! 24 Gemfile dependencies, 96 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed.
seen

2018/05/01 13:57

herokuプッシュ結果 $ git push heroku master Counting objects: 21, done. Compressing objects: 100% (14/14), done. Writing objects: 100% (14/14), 295.84 KiB, done. Total 14 (delta 7), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Ruby app detected remote: -----> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-2.3.4 remote: -----> Installing dependencies using bundler 1.15.2 remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment remote: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. remote: Fetching gem metadata from https://rubygems.org/........ remote: Fetching version metadata from https://rubygems.org/.. remote: Fetching dependency metadata from https://rubygems.org/. remote: Using rake 12.3.0 remote: Using concurrent-ruby 1.0.5 remote: Using minitest 5.11.3 remote: Using thread_safe 0.3.6 remote: Using builder 3.2.3 remote: Using erubi 1.7.1 remote: Using mini_portile2 2.3.0 remote: Using crass 1.0.3 remote: Using rack 2.0.4 remote: Using nio4r 2.2.0 remote: Using websocket-extensions 0.1.3 remote: Using mini_mime 1.0.0 remote: Using arel 8.0.0 remote: Using execjs 2.7.0 remote: Fetching aws_cf_signer 0.1.3 remote: Using bcrypt 3.1.11 remote: Using rb-fsevent 0.10.3 remote: Using ffi 1.9.23 remote: Using bundler 1.15.2 remote: Using mime-types-data 3.2016.0521 remote: Fetching unf_ext 0.0.7.5 remote: Fetching netrc 0.11.0 remote: Installing aws_cf_signer 0.1.3 remote: Installing netrc 0.11.0 remote: Using coffee-script-source 1.12.2 remote: Using method_source 0.9.0 remote: Using thor 0.20.0 remote: Using orm_adapter 0.5.0 remote: Using multi_json 1.13.1 remote: Using libv8 3.16.14.19 (x86_64-linux) remote: Using pg 1.0.0 remote: Using puma 3.11.3 remote: Using rails_serve_static_assets 0.0.5 remote: Using rails_stdout_logging 0.0.5 remote: Using ref 2.0.0 remote: Using rmagick 2.16.0 remote: Using tilt 2.0.8 remote: Using turbolinks-source 5.1.0 remote: Using tzinfo 1.2.5 remote: Using nokogiri 1.8.2 remote: Using rack-test 0.8.3 remote: Using warden 1.2.7 remote: Using websocket-driver 0.6.5 remote: Using mail 2.7.0 remote: Using autoprefixer-rails 8.1.0.1 remote: Using uglifier 4.1.6 remote: Using i18n 0.9.5 remote: Using sprockets 3.7.1 remote: Using rb-inotify 0.9.10 remote: Using mime-types 3.1 remote: Using coffee-script 2.4.1 remote: Using rails_12factor 0.0.3 remote: Using therubyracer 0.12.3 remote: Using turbolinks 5.1.0 remote: Using loofah 2.2.0 remote: Using activesupport 5.1.5 remote: Using sass-listen 4.0.0 remote: Using rails-html-sanitizer 1.0.3 remote: Using sass 3.5.5 remote: Using rails-dom-testing 2.0.3
seen

2018/05/01 13:58

remote: Using globalid 0.4.1 remote: Using activemodel 5.1.5 remote: Using jbuilder 2.7.0 remote: Using actionview 5.1.5 remote: Using bootstrap-sass 3.3.7 remote: Using activerecord 5.1.5 remote: Using carrierwave 1.2.2 remote: Using actionpack 5.1.5 remote: Using activejob 5.1.5 remote: Using actioncable 5.1.5 remote: Using actionmailer 5.1.5 remote: Using railties 5.1.5 remote: Using sprockets-rails 3.2.1 remote: Using coffee-rails 4.2.2 remote: Using responders 2.4.0 remote: Using jquery-rails 4.3.1 remote: Using rails 5.1.5 remote: Using sass-rails 5.0.7 remote: Using devise 4.4.3 remote: Installing unf_ext 0.0.7.5 with native extensions remote: Fetching unf 0.1.4 remote: Installing unf 0.1.4 remote: Fetching domain_name 0.5.20180417 remote: Installing domain_name 0.5.20180417 remote: Fetching http-cookie 1.0.3 remote: Installing http-cookie 1.0.3 remote: Fetching rest-client 2.0.2 remote: Installing rest-client 2.0.2 remote: Fetching cloudinary 1.9.1 remote: Installing cloudinary 1.9.1 remote: Bundle complete! 24 Gemfile dependencies, 82 gems now installed. remote: Gems in the groups development and test were not installed. remote: Bundled gems are installed into ./vendor/bundle. remote: Bundle completed (5.65s) remote: Cleaning up the bundler cache. remote: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. remote: The latest bundler is 1.16.1, but you are currently running 1.15.2. remote: To update, run `gem install bundler` remote: -----> Installing node-v8.10.0-linux-x64 remote: Detected manifest file, assuming assets were compiled locally remote: remote: ###### WARNING: remote: You have not declared a Ruby version in your Gemfile. remote: To set your Ruby version add this line to your Gemfile: remote: ruby '2.3.4' remote: # See https://devcenter.heroku.com/articles/ruby-versions for more information. remote: remote: -----> Node.js app detected remote: remote: -----> Creating runtime environment remote: remote: NPM_CONFIG_LOGLEVEL=error remote: NODE_VERBOSE=false remote: NODE_ENV=production remote: NODE_MODULES_CACHE=true
seen

2018/05/01 13:59

remote: remote: -----> Installing binaries remote: engines.node (package.json): unspecified remote: engines.npm (package.json): unspecified (use default) remote: remote: Resolving node version 8.x... remote: Downloading and installing node 8.11.1... remote: Using default npm version: 5.6.0 remote: remote: -----> Restoring cache remote: Loading 2 from cacheDirectories (default): remote: - node_modules (not cached - skipping) remote: - bower_components (not cached - skipping) remote: remote: -----> Building dependencies remote: Installing node modules (package.json) remote: up to date in 0.072s remote: remote: -----> Caching build remote: Clearing previous node cache remote: Saving 2 cacheDirectories (default): remote: - node_modules (nothing to cache) remote: - bower_components (nothing to cache) remote: remote: -----> Pruning devDependencies remote: Skipping because npm 5.6.0 sometimes fails when running 'npm prune' due to a known issue remote: https://github.com/npm/npm/issues/19356 remote: remote: You can silence this warning by updating to at least npm 5.7.1 in your package.json remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-an-npm-version remote: remote: -----> Build succeeded! remote: -----> Discovering process types remote: Procfile declares types -> web remote: remote: -----> Compressing... remote: Done: 111.2M remote: -----> Launching... remote: Released v10 remote: https://******.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy... done. To https://git.heroku.com/****.git bbaa5cc..ff87413 master -> master
seen

2018/05/01 14:00

よろしくお願いします。
seen

2018/05/01 14:24

あ! でもアプリの記事的な登録で画像をアップロードしたらちゃんと反映されました!!(10分弱かかりましたが) cssのデザインとしてapp/assets/images以下に置いてあるものはheroku pushしても反映されないですね。  heroku側ではcloudinaryに置かないといけないので、pushしただけでは置いてくれていないということですかね?
退会済みユーザー

退会済みユーザー

2018/05/02 02:50

そうですね。Herokuではapp/assets/images下に置かれている画像は読み込まれないです。cloudinaryにアップした画像にはURLが付与されているはずなので、viewで<img src="{画像URL}">のように書けば任意の場所で表示させられると思います。
seen

2018/05/03 15:36

すみません、時間をおいてから自アプリを確認すると投稿した画像が消えていました。 cloudinaryに画像を保存出来ていないと思うのですが、 参考にしたこちらのサイトで http://mutipuro.xyz/rails-heroku-gazou/ 少し迷ったところがありまして $ heroku addons:create cloudinary:starter を実行するとは書かれていないので実行していないのですがこれは実行する必要があるのでしょうか?
退会済みユーザー

退会済みユーザー

2018/05/03 16:40

ブラウザ側で導入したのであれば実行する必要はないと思います。私はcloudinaryを使ったことはないのですが、cloudinaryのブラウザコンソール画面でアップロードされているかの確認はできると思いますので、一度見てみて下さい。
seen

2018/05/04 03:05

herokuのブラウザコンソールからcloudinaryのブラウザコンソール画面を開いて確認しました。 formから投稿した画像は反映されていないです。 cssのデザイン関係の画像はそこに手動でアップロードしてURLで呼び出し表示させることが出来ました。 投稿したものがアップロードできない件は別途調べてみます。 なにか情報をお持ちでしたら教えていただけると幸いです。 お手数ですがよろしくお願いします。
退会済みユーザー

退会済みユーザー

2018/05/04 04:32 編集

手動アップロードできたようでよかったです。すみませんが、cloudinaryに関しては私がお役に立てるのはここまでですね…cloudinaryの質問を新たに立てることで回答を募れるかと思いますのでご検討下さい。
seen

2018/05/04 04:36

お手数おかけしました。 助かりました! ありがとうございます!
退会済みユーザー

退会済みユーザー

2018/05/04 04:36

いえ、完成できるよう頑張って下さい。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問