使用capistrano部署时找不到错误命令webpack

时间:2019-02-10 07:46:09

标签: ruby-on-rails node.js npm webpack capistrano3

ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
00:00 git:wrapper
  01 mkdir -p /tmp
✔ 01 root@157.230.93.52 2.312s
  Uploading /tmp/git-ssh-jec_access-production-jeanlinux.sh 100.0%
  02 chmod 700 /tmp/git-ssh-jec_access-production-jeanlinux.sh
✔ 02 root@157.230.93.52 1.210s
00:08 git:check
  01 git ls-remote git@bitbucket.com:jeanlinux/jecaccess.git HEAD
  01 02704634ef3fea8fb4ef983aa8a71b184f55f2cd       HEAD
✔ 01 root@157.230.93.52 4.701s
00:13 deploy:check:directories
  01 mkdir -p /home/deploy/JecAccess/shared /home/deploy/JecAccess/releases
✔ 01 root@157.230.93.52 0.721s
00:13 deploy:check:linked_dirs
  01 mkdir -p /home/deploy/JecAccess/shared/log /home/deploy/JecAccess/shared/tmp/pids /home/deploy/JecAccess/shared/tmp/cache /home/deploy/JecAccess/shared/tmp/sockets /home/deploy/JecAcce…
✔ 01 root@157.230.93.52 2.250s
00:16 deploy:check:make_linked_dirs
  01 mkdir -p /home/deploy/JecAccess/shared/config
✔ 01 root@157.230.93.52 1.022s
00:22 git:clone
  The repository mirror is at /home/deploy/JecAccess/repo
00:24 git:update
  01 git remote set-url origin git@bitbucket.com:jeanlinux/jecaccess.git
✔ 01 root@157.230.93.52 1.063s
  02 git remote update --prune
  02 Fetching origin
✔ 02 root@157.230.93.52 3.030s
00:30 git:create_release
  01 mkdir -p /home/deploy/JecAccess/releases/20190210065936
✔ 01 root@157.230.93.52 0.920s
  02 git archive master | /usr/bin/env tar -x -f - -C /home/deploy/JecAccess/releases/20190210065936
✔ 02 root@157.230.93.52 1.636s
00:36 deploy:set_current_revision
  01 echo "02704634ef3fea8fb4ef983aa8a71b184f55f2cd" > REVISION
✔ 01 root@157.230.93.52 2.451s
00:38 deploy:symlink:linked_files
  01 mkdir -p /home/deploy/JecAccess/releases/20190210065936/config
✔ 01 root@157.230.93.52 1.233s
  02 rm /home/deploy/JecAccess/releases/20190210065936/config/database.yml
✔ 02 root@157.230.93.52 2.587s
  03 ln -s /home/deploy/JecAccess/shared/config/database.yml /home/deploy/JecAccess/releases/20190210065936/config/database.yml
✔ 03 root@157.230.93.52 0.893s
  04 rm /home/deploy/JecAccess/releases/20190210065936/config/secrets.yml
✔ 04 root@157.230.93.52 1.192s
  05 ln -s /home/deploy/JecAccess/shared/config/secrets.yml /home/deploy/JecAccess/releases/20190210065936/config/secrets.yml
✔ 05 root@157.230.93.52 4.403s
00:56 deploy:symlink:linked_dirs
  01 mkdir -p /home/deploy/JecAccess/releases/20190210065936 /home/deploy/JecAccess/releases/20190210065936/tmp /home/deploy/JecAccess/releases/20190210065936/public
✔ 01 root@157.230.93.52 1.101s
  02 rm -rf /home/deploy/JecAccess/releases/20190210065936/log
✔ 02 root@157.230.93.52 0.852s
  03 ln -s /home/deploy/JecAccess/shared/log /home/deploy/JecAccess/releases/20190210065936/log
✔ 03 root@157.230.93.52 1.158s
  04 ln -s /home/deploy/JecAccess/shared/tmp/pids /home/deploy/JecAccess/releases/20190210065936/tmp/pids
✔ 04 root@157.230.93.52 3.071s
  05 ln -s /home/deploy/JecAccess/shared/tmp/cache /home/deploy/JecAccess/releases/20190210065936/tmp/cache
✔ 05 root@157.230.93.52 0.942s
  06 ln -s /home/deploy/JecAccess/shared/tmp/sockets /home/deploy/JecAccess/releases/20190210065936/tmp/sockets
✔ 06 root@157.230.93.52 0.727s
  07 ln -s /home/deploy/JecAccess/shared/public/system /home/deploy/JecAccess/releases/20190210065936/public/system
✔ 07 root@157.230.93.52 1.159s
  08 ln -s /home/deploy/JecAccess/shared/public/assets /home/deploy/JecAccess/releases/20190210065936/public/assets
✔ 08 root@157.230.93.52 1.433s
01:27 bundler:install
  01 /usr/local/rvm/bin/rvm default do bundle install --path /home/deploy/JecAccess/shared/bundle --jobs 4 --without development test --deployment --quiet
✔ 01 root@157.230.93.52 2.707s
01:33 deploy:assets:precompile
  01 /usr/local/rvm/bin/rvm default do bundle exec rake assets:precompile
  01 Webpacker is installed  
  01 Using /home/deploy/JecAccess/releases/20190210065936/config/webpacker.yml file for setting up webpack paths
  01 Compiling…
  01 Compilation failed:
  01 yarn run v1.13.0
  01 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  01
  01 warning ../../package.json: No license field
  01 warning From Yarn 1.0 onwards, scripts don't require "--" for options to be forwarded. In a future version, any explicit "--" will be forwarded as-is to the scripts.
  01 error Command "webpack" not found.
  01
  

(回溯仅限于导入的任务)上限已终止!   SSHKit :: Runner :: ExecuteError:在主机上执行时发生异常   157.230.93.52:rake退出状态:1 rake stdout:Webpacker已安装使用   /home/deploy/JecAccess/releases/20190210065936/config/webpacker.yml   用于设置webpack路径的文件编译中…编译失败:yarn   运行v1.13.0 info访问https://yarnpkg.com/en/docs/cli/run   有关此命令的文档。

     

警告../../package.json:没有许可证字段警告来自Yarn 1.0   从此以后,脚本不需要“-”就可以转发选项。在一个   未来版本中,任何明确的“-”都将原样转发给   脚本。错误找不到命令“ webpack”。瑞克·斯特德:什么都没有   书面

     

由以下原因引起:SSHKit :: Command :: Failed:rake exit status:1 rake stdout:   Webpacker安装使用   /home/deploy/JecAccess/releases/20190210065936/config/webpacker.yml   用于设置webpack路径的文件编译中…编译失败:yarn   运行v1.13.0 info访问https://yarnpkg.com/en/docs/cli/run   有关此命令的文档。

     

警告../../package.json:没有许可证字段警告来自Yarn 1.0   从此以后,脚本不需要“-”就可以转发选项。在一个   未来版本中,任何明确的“-”都将原样转发给   脚本。错误找不到命令“ webpack”。瑞克·斯特德:什么都没有   书面

     

任务:TOP => deploy:assets:precompile(通过运行任务查看完整跟踪   --trace)部署失败,并显示以下错误:Exception when   在主机157.230.93.52上执行:rake退出状态:1 rake stdout:   Webpacker安装使用   /home/deploy/JecAccess/releases/20190210065936/config/webpacker.yml   用于设置webpack路径的文件编译中…编译失败:yarn   运行v1.13.0 info访问https://yarnpkg.com/en/docs/cli/run   有关此命令的文档。

     

警告../../package.json:没有许可证字段警告来自Yarn 1.0   从此以后,脚本不需要“-”就可以转发选项。在一个   未来版本中,任何明确的“-”都将原样转发给   脚本。错误找不到命令“ webpack”。瑞克·斯特德:什么都没有   书面

     

**部署失败   **有关详细信息,请参阅log / capistrano.log。这是最后20行:

     

DEBUG [5607bacb]在2.268秒内完成,退出状态为1   (失败)。

     

INFO [9d26f1fe]运行/ usr / local / rvm / bin / rvm默​​认做捆绑   安装--path / home / deploy / JecAccess / shared / bundle --jobs 4 --without   开发测试--deployment --quiet on 157.230.93.52

     

DEBUG [9d26f1fe]命令:cd   / home / deploy / JecAccess / releases / 20190210065936 &&   / usr / local / rvm / bin / rvm默​​认不捆绑安装--path   / home / deploy / JecAccess / shared / bundle --jobs 4-无开发   测试-部署-安静

     

INFO [2c0ee907]在2.707秒内完成,退出状态为0   (成功)。

     

调试[99f77c18]如果测试运行! -d   / home / deploy / JecAccess / releases / 20190210065936;然后回显“目录   不存在'/ home / deploy / JecAccess / releases / 20190210065936'“ 1>&2;   假; fi在157.230.93.52

     

DEBUG [99f77c18]命令:如果测试! -d   / home / deploy / JecAccess / releases / 20190210065936;然后回显“目录   不存在'/ home / deploy / JecAccess / releases / 20190210065936'“ 1>&2;   假; fi

     

DEBUG [50cd673a]在2.866秒内完成,退出状态为0   (成功)。

     

INFO [407a8274]运行/ usr / local / rvm / bin / rvm默​​认情况下做捆绑   exec rake资产:在157.230.93.52上预编译

     

DEBUG [407a8274]命令:cd   / home / deploy / JecAccess / releases / 20190210065936 &&(导出   RAILS_ENV =“ production” RAILS_GROUPS =“”; / usr / local / rvm / bin / rvm   默认不捆绑exec rake asset:precompile)

     

已安装调试[6bf4baca] Webpacker

     

使用   /home/deploy/JecAccess/releases/20190210065936/config/webpacker.yml   用于设置webpack路径的文件

     

调试[6bf4baca]正在编译…

     

调试[6bf4baca]编译失败:

     

纱线运行v1.13.0

     

info访问https://yarnpkg.com/en/docs/cli/run以获得有关以下内容的文档   该命令。

     

警告../../package.json:没有许可证字段

     

警告从Yarn 1.0开始,脚本不需要“-”作为选项   待转发。在将来的版本中,任何明确的“-”将   照原样转发到脚本。

     

找不到错误命令“ webpack”。

2 个答案:

答案 0 :(得分:0)

您需要在asset:precompile之前安装运行任务yarn。

查看文档

https://github.com/rails/webpacker/blob/master/docs/deployment.md

答案 1 :(得分:0)

您需要将其添加到config/deploy.rb的底部:

before "deploy:assets:precompile", "deploy:yarn_install"
namespace :deploy do
  desc "Run rake yarn install"
  task :yarn_install do
    on roles(:web) do
      within release_path do
        execute("cd #{release_path} && yarn install --silent --no-progress --no-audit --no-optional")
      end
    end
  end
end

https://github.com/rails/webpacker/blob/master/docs/deployment.md

获得了此代码