Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

環境

・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

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした