推送到Heroku时,webpacker无法编译

时间:2019-05-15 00:35:48

标签: ruby-on-rails reactjs webpacker

我最近尝试通过使用webpacker gem将react集成到我现有的Rails应用程序中。当我尝试推送到heroku时,我看到一条错误消息,例如

remote:        [1/5] Validating package.json...
remote:        [2/5] Resolving packages...
remote:        [3/5] Fetching packages...
remote:        [4/5] Linking dependencies...
remote:        [5/5] Building fresh packages...
remote:        success Saved lockfile.
remote:        Done in 0.09s.
remote:        Compiling…
remote:        Compilation failed:
remote:        error Command "webpack" not found.
remote:        
remote:        yarn run v1.12.3
remote:        info Visit https://yarnpkg.com/en/docs/cli/run for 
documentation about this command.
remote:        
remote: 
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to spitball-production.
remote: 
To https://git.heroku.com/spitball-production.git
 ! [remote rejected] master -> master (pre-receive hook declined)

我的package.json看起来像

{
   "name": "Spitball",
   "private": true,
   "dependencies": {
    },
   "engines": {
   "yarn": ">=0.25.2"
   }
}

我尝试了涉及添加构建包以及安装yarn和webpacker的解决方案,到目前为止,没有任何帮助。我希望一切都会顺利进行,因为我所做的只是添加了webpacker gem。

1 个答案:

答案 0 :(得分:0)

您尝试运行

$ rails assets:precompile

在您的终端中先推送到Github,然后再推送到Heroku? 您必须先编译所有资产文件,然后才能由Heroku构建。