LoginSignup
82
55

More than 5 years have passed since last update.

Cloud9でHerokuが使えない時の対処法

Last updated at Posted at 2017-12-29

環境

・CLoud9

Cloud9でHerokuを使おうとしたらエラーが出た

Cloud9のターミナルで

$ heroku -v

と打つと

heroku: command not found

と帰ってきた。

ネットで調べると、似たような症状の解決策があったので実行。

以下のコマンドを順に実行した

$ sudo yum -y update
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
$ export NVM_DIR=”/home/ec2-user/.nvm”
$ [ -s “$NVM_DIR/nvm.sh” ] && \. “$NVM_DIR/nvm.sh”
$ nvm install node --reinstall-packages-from=node
$ npm install -g cli-engine-command@8.0.0
$ npm install -g heroku-cli

途中までうまくいっていたが、最後のコマンドで下記のようなエラーが出た。

npm WARN cli-engine-heroku@4.1.1 requires a peer of cli-engine-command@^8.0.0 but none was installed.

一旦無視してheroku使えるかどうか試してみた。

$ heroku -v
WARNING
WARNING Node version must be >=8.3.0 to use the Heroku CLI
WARNING
/home/ec2-user/.nvm/versions/node/v6.11.4/lib/node_modules/heroku-cli/node_modules/cli-engine/lib/cli.js:68
  async run() {
        ^^^

node.jsのバージョンを8.3.0にしろと言っている。(現状は6.11.4)
この記事を参考にnodeのアップデートを行なった。

node.jsのアップデート

バージョン確認

$ node -v
v6.11.4

8.3.0にアップデート

$ nvm install v8.3.0
Downloading https://nodejs.org/dist/v8.3.0/node-v8.3.0-linux-x64.tar.xz...
######################################################################## 100.0%
nvm is not compatible with the npm config "prefix" option: currently set to "/home/ec2-user/environment/”/home/ec2-user/.nvm”/versions/node/v8.3.0"
Run `npm config delete prefix` or `nvm use --delete-prefix v8.3.0` to unset it.

「npm config delete prefix」か「nvm use --delete-prefix v8.3.0」しろと言われる。

nvm use --delete-prefix v8.3.0する

$ nvm use --delete-prefix v8.3.0
Now using node v8.3.0 (npm v5.3.0)

nodeの8.3.0が使えるようになったみたい。

念のためバージョン確認

$ node -v
v8.3.0

よし。

そしてHerokuチャレンジ

$ heroku -v
heroku-cli/6.14.43 (linux-x64) node-v8.3.0

よっしゃ。使えるようになった!

82
55
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
82
55