[RUBY] Errors and solutions and reference articles that occurred when putting Heroku in Vagrant

Introduction

Since the application is developed and published in the local environment built by dot installation, an error occurred when I tried to install heroku. [[For beginners] How to reliably deploy rails app using heroku [Definitive edition]](https://qiita.com/kazukimatsumoto/items/a0daa7281a3948701c39#%E8%87%AA%E5%88%86% E3% 81% AE% E7% 92% B0% E5% A2% 83) I was referring to this article. However, when I installed heroku, the development environment for this article was completely different, so I couldn't go any further and had to fight the error.

No path problem

I didn't make a copy of the error because I was desperate to resolve it, but I think I got an error like this.

↓ Last sentence of error
Your path is missing /usr/local/bin, you need to add this to use this installer.

It is said that there is no path for / usr / local / bin, so it seems that you need to create a path.

Check the path

$ echo $PATH

I will check the path, but it seems that it is useless if there is / usr / local / bin: but there is no / usr / local / bin.

Knowledge learned during the solution before the solution

sudo is a command with high authority in my interpretation. There is also a difference between $ and #, and # has higher authority. (Because I was able to do what I couldn't do with $ with#)

Solution: Use great permissions or rewrite with the vi editor.

Refer to the following for the .bash_profile and sudo settings required to set the path. What you want to set after building the virtual environment-Memo-

This is kinder to set sudo. Inherit the PATH of the executing user when sudo on CentOS

$ sudo visudo

Since it was necessary to operate the vi editor after executing, I referred to the following. How to use the vi editor

If you think the pass has passed, syntax error problem

$ heroku --version

When I check the version of heroku, I get the following error ...

/usr/local/lib/heroku/node_modules/@oclif/command/lib/index.js:3
const path = require("path");
^^^^^
SyntaxError: Use of const in strict mode.
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/local/lib/heroku/bin/run:5:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

It seems that the version of Node.js is too old.

$ node -v

When I checked it, it was v0.10.48.

Solution: Clear the cache and insert a new version.

I've tried many things and I'm sorry if it doesn't work as a direct solution.

npm was not installed, so I installed it. Also install node. I don't know if I need npm to get Heroku, but I installed it for now.

$ sudo yum install nodejs npm

Go towards great authority.

$ sudo -s

The one on the left changes from $ to #.

The one you need to install (honestly, I'm not sure, but specify the version to install in the number part of setup_11.x.)

# curl --silent --location https://rpm.nodesource.com/setup_11.x | bash 

From here, I've been installing and uninstalling repeatedly, so I'm sorry if the procedure is wrong. I referred to the following. I want you to read it ahead. Story and solution for nodejs version upgrade on yum

Delete the old rpm.

# rm /etc/yum.repos.d/nodesource-el.repo

Uninstall.

# yum -y remove nodejs

Delete the cache.

# yum clean all

install.

# yum -y install nodejs

Check the version.

# node -v
v11.15.0

It's a success! And get out of great authority.

# su vagrant

Also check the version of heroku

$ heroku -v
heroku/7.44.0 linux-x64 node-v11.15.0

Other reference articles. https://qiita.com/daskepon/items/16a77868d38f8e585840 https://inaba.hatenablog.com/entry/2018/11/13/023933

Article with almost the same error https://teratail.com/questions/256490

Thanks

We would like to thank all the site administrators for their reference.

Recommended Posts

Errors and solutions and reference articles that occurred when putting Heroku in Vagrant
Introducing the settings and reference articles that are first done in Rails new development
Blogs and articles that helped me when facing JSON
[Docker] List of errors that occurred when building the environment
Problems and solutions for UI collapse when inputting Japanese in swing
Resolved the error that occurred when trying to use Spark in an environment where Java 8 and Java 11 coexist.