ruby-on-rails - 使用 capistrano 部署时未找到错误命令 webpack

标签 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

(Backtrace restricted to imported tasks) cap aborted! SSHKit::Runner::ExecuteError: Exception while executing on host 157.230.93.52: rake exit status: 1 rake stdout: Webpacker is installed 🎉 🍰 Using /home/deploy/JecAccess/releases/20190210065936/config/webpacker.yml file for setting up webpack paths Compiling… Compilation failed: yarn run v1.13.0 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

warning ../../package.json: No license field 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. error Command "webpack" not found. rake stderr: Nothing written

Caused by: SSHKit::Command::Failed: rake exit status: 1 rake stdout: Webpacker is installed 🎉 🍰 Using /home/deploy/JecAccess/releases/20190210065936/config/webpacker.yml file for setting up webpack paths Compiling… Compilation failed: yarn run v1.13.0 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

warning ../../package.json: No license field 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. error Command "webpack" not found. rake stderr: Nothing written

Tasks: TOP => deploy:assets:precompile (See full trace by running task with --trace) The deploy has failed with an error: Exception while executing on host 157.230.93.52: rake exit status: 1 rake stdout: Webpacker is installed 🎉 🍰 Using /home/deploy/JecAccess/releases/20190210065936/config/webpacker.yml file for setting up webpack paths Compiling… Compilation failed: yarn run v1.13.0 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

warning ../../package.json: No license field 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. error Command "webpack" not found. rake stderr: Nothing written

** DEPLOY FAILED ** Refer to log/capistrano.log for details. Here are the last 20 lines:

DEBUG [5607bacb] Finished in 2.268 seconds with exit status 1 (failed).

INFO [9d26f1fe] Running /usr/local/rvm/bin/rvm default do bundle install --path /home/deploy/JecAccess/shared/bundle --jobs 4 --without development test --deployment --quiet on 157.230.93.52

DEBUG [9d26f1fe] Command: cd /home/deploy/JecAccess/releases/20190210065936 && /usr/local/rvm/bin/rvm default do bundle install --path /home/deploy/JecAccess/shared/bundle --jobs 4 --without development test --deployment --quiet

INFO [2c0ee907] Finished in 2.707 seconds with exit status 0 (successful).

DEBUG [99f77c18] Running if test ! -d /home/deploy/JecAccess/releases/20190210065936; then echo "Directory does not exist '/home/deploy/JecAccess/releases/20190210065936'" 1>&2; false; fi on 157.230.93.52

DEBUG [99f77c18] Command: if test ! -d /home/deploy/JecAccess/releases/20190210065936; then echo "Directory does not exist '/home/deploy/JecAccess/releases/20190210065936'" 1>&2; false; fi

DEBUG [50cd673a] Finished in 2.866 seconds with exit status 0 (successful).

INFO [407a8274] Running /usr/local/rvm/bin/rvm default do bundle exec rake assets:precompile on 157.230.93.52

DEBUG [407a8274] Command: cd /home/deploy/JecAccess/releases/20190210065936 && ( export RAILS_ENV="production" RAILS_GROUPS="" ; /usr/local/rvm/bin/rvm default do bundle exec rake assets:precompile )

DEBUG [6bf4baca] Webpacker is installed 🎉 🍰

Using /home/deploy/JecAccess/releases/20190210065936/config/webpacker.yml file for setting up webpack paths

DEBUG [6bf4baca] Compiling…

DEBUG [6bf4baca] Compilation failed:

yarn run v1.13.0

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

warning ../../package.json: No license field

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.

error Command "webpack" not found.

最佳答案

您需要将其添加到 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 获取此代码

关于ruby-on-rails - 使用 capistrano 部署时未找到错误命令 webpack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54614418/

相关文章:

javascript - 我无法安装 "npm install semantic-ui-react semantic-ui-css",我该怎么办?

ruby-on-rails - 如何比较 Float 和 Nil 以返回有效答案?

mysql - Rails 3- 嵌套对象形式(重用地址模型)

node.js - 错误: Connection Closed - MongoDB Node

node.js - 动态运行 Mocha 测试

javascript - 修复安装 NPM 包的上游依赖冲突

javascript - 属性未传递给购物车商品的 AJAX 调用

php - 将 PHP 和 Rails 放在同一服务器上

javascript - 如何在解析服务器上使用 kue 安排作业?

javascript - 如何在 React JS 中执行基于条件的不重复自己(干)原则?