Rails6에서 앱을 시작할 때 Webpacker configuration file not found 오류가 발생했을 때의 해결 방법
쓰기 배경
scaffold를 사용하여 간단한 앱을 만들려고 다음 명령을 입력하면 Webpacker가 설치되어 있지 않다는 오류가 발생했기 때문에 작성해 봅시다.
$ rails new app_name
$ cd app
$ rails g scaffold post content:text
$ rails db:migrate
$ rails s
(中略)
Webpacker configuration file not found /Users/ユーザ名/app_name/config/webpacker.yml.
Please run rails webpacker:install 
Error: No such file or directory 
@ rb_sysopen - /Users/ユーザ名/app_name/config/webpacker.yml 
(RuntimeError)
덧붙여서, 이때 루비 버전은 2.7.0, rails 버전은 6.0.2.2입니다.
 결론
이 오류는 webpacker가 설치되어 있지 않은 경우에 발생하는 오류와 같습니다 (rails6에서 webpacker가 표준이 되었기 때문에).
webpacker를 설치하려면 Node.js와 Yarn을 설치해야 합니다.
 작업 내용
Gemfile을 확인하고 gem 'webpacker'의 설명을 확인.
Gemfilegem 'webpacker', '~> 4.0'
bundle install 한 후 webpacker를 설치하려고 시도도 Node.js가 설치되어 있지 않으면 화난다.
$ bundle install
$ rails webpacker:install
sh: node: command not found
sh: nodejs: command not found
Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/
Node.js를 설치 한 후 webpacker를 다시 설치하려고하면 Yarn을 설치하려고 화가납니다.
$ brew install node
(中略)
==> node
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
$ rails webpacker:install
Yarn not installed. 
Please download and install 
Yarn from https://yarnpkg.com/lang/en/docs/install/
Yarn을 설치한 후, 다시 webpacker의 설치를 시도했더니 설치할 수 있었다.
$ sudo npm install -g yarn
added 1 package in 3.509s
$ yarn -v
1.22.4
$ yarn install
success Saved lockfile.
✨  Done in 3.49s.
$ rails webpacker:install
✨  Done in 6.34s.
Webpacker successfully installed 🎉 🍰
앱을 다시 시작합니다.
$ rails s
Use Ctrl-C to stop
Started GET "/posts/index" for ::1 at 2020-03-28 18:06:09 +0900
잘 갔다!
  
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(Rails6에서 앱을 시작할 때 Webpacker configuration file not found 오류가 발생했을 때의 해결 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/hasegawa-naoto/items/a2c2900c3f4f05ee3bcb
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
$ rails new app_name
$ cd app
$ rails g scaffold post content:text
$ rails db:migrate
$ rails s
(中略)
Webpacker configuration file not found /Users/ユーザ名/app_name/config/webpacker.yml.
Please run rails webpacker:install 
Error: No such file or directory 
@ rb_sysopen - /Users/ユーザ名/app_name/config/webpacker.yml 
(RuntimeError)
이 오류는 webpacker가 설치되어 있지 않은 경우에 발생하는 오류와 같습니다 (rails6에서 webpacker가 표준이 되었기 때문에).
webpacker를 설치하려면 Node.js와 Yarn을 설치해야 합니다.
작업 내용
Gemfile을 확인하고 gem 'webpacker'의 설명을 확인.
Gemfilegem 'webpacker', '~> 4.0'
bundle install 한 후 webpacker를 설치하려고 시도도 Node.js가 설치되어 있지 않으면 화난다.
$ bundle install
$ rails webpacker:install
sh: node: command not found
sh: nodejs: command not found
Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/
Node.js를 설치 한 후 webpacker를 다시 설치하려고하면 Yarn을 설치하려고 화가납니다.
$ brew install node
(中略)
==> node
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
$ rails webpacker:install
Yarn not installed. 
Please download and install 
Yarn from https://yarnpkg.com/lang/en/docs/install/
Yarn을 설치한 후, 다시 webpacker의 설치를 시도했더니 설치할 수 있었다.
$ sudo npm install -g yarn
added 1 package in 3.509s
$ yarn -v
1.22.4
$ yarn install
success Saved lockfile.
✨  Done in 3.49s.
$ rails webpacker:install
✨  Done in 6.34s.
Webpacker successfully installed 🎉 🍰
앱을 다시 시작합니다.
$ rails s
Use Ctrl-C to stop
Started GET "/posts/index" for ::1 at 2020-03-28 18:06:09 +0900
잘 갔다!
  
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(Rails6에서 앱을 시작할 때 Webpacker configuration file not found 오류가 발생했을 때의 해결 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/hasegawa-naoto/items/a2c2900c3f4f05ee3bcb
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
gem 'webpacker', '~> 4.0'
$ bundle install
$ rails webpacker:install
sh: node: command not found
sh: nodejs: command not found
Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/
$ brew install node
(中略)
==> node
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
$ rails webpacker:install
Yarn not installed. 
Please download and install 
Yarn from https://yarnpkg.com/lang/en/docs/install/
$ sudo npm install -g yarn
added 1 package in 3.509s
$ yarn -v
1.22.4
$ yarn install
success Saved lockfile.
✨  Done in 3.49s.
$ rails webpacker:install
✨  Done in 6.34s.
Webpacker successfully installed 🎉 🍰
$ rails s
Use Ctrl-C to stop
Started GET "/posts/index" for ::1 at 2020-03-28 18:06:09 +0900
Reference
이 문제에 관하여(Rails6에서 앱을 시작할 때 Webpacker configuration file not found 오류가 발생했을 때의 해결 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/hasegawa-naoto/items/a2c2900c3f4f05ee3bcb텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)