我正在尝试部署使用rails / webpacker编译反应组件的Rails5应用程序。部署失败,出现以下错误。我正在使用Capistrano3。
Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as fumiya@xx.xx.xxx.xx: rake exit status: 1
rake stdout: yarn install v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
info "fsevents@1.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 4.91s.
rake stderr: I, [2017-07-14T08:42:46.754828 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/admin/active_admin-3874d71151f24042a1a0a69719e5c5e015061e1974ea73f420eba87fcfa497c8.js
I, [2017-07-14T08:42:46.755310 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/admin/active_admin-3874d71151f24042a1a0a69719e5c5e015061e1974ea73f420eba87fcfa497c8.js.gz
I, [2017-07-14T08:42:48.120247 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/admin/active_admin-b2184d0cbd678145f43194b8ff874796edf5e63efa423b18b3c81a45de8f048b.css
I, [2017-07-14T08:42:48.120778 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/admin/active_admin-b2184d0cbd678145f43194b8ff874796edf5e63efa423b18b3c81a45de8f048b.css.gz
I, [2017-07-14T08:42:48.121098 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/active_admin/nested_menu_arrow-15084d93c65c1964d7077700ea748bd2d70cfa2d4c19707c58a9c64e232dd442.gif
I, [2017-07-14T08:42:48.123012 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/active_admin/nested_menu_arrow_dark-7c43b8e0a5f8823875f49a093c9d7a6b374f885b6f9cc248ae9cd7e6e9b29034.gif
I, [2017-07-14T08:42:48.123429 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/active_admin/orderable-29374dbb55b0012d78a37c614d573bb3474f0779849b478a147d0f1845ca6617.png
062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/sp/application-5be34faf9363b508575e153f7a6e0fbcec39e927ded5304754123fe8cf49e221.css
I, [2017-07-14T08:43:08.233346 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/sp/application-5be34faf9363b508575e153f7a6e0fbcec39e927ded5304754123fe8cf49e221.css.gz
warning package.json: No license field
warning No license field
warning fsevents@1.1.2: The platform "linux" is incompatible with this module.
warning "react-dnd-html5-backend@2.4.1" has unmet peer dependency "react-dnd@^2.4.0".
warning "react-moment@0.2.4" has unmet peer dependency "moment-timezone@^0.5.11".
** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:
DEBUG [bff04de7] I, [2017-07-14T08:42:57.040184 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/pc/application-4ef41cee193db3216a732cb422f172ff1ee9f30dd1b8590ec8b99681eb535081.js
DEBUG [bff04de7] I, [2017-07-14T08:42:57.041067 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/pc/application-4ef41cee193db3216a732cb422f172ff1ee9f30dd1b8590ec8b99681eb535081.js.gz
DEBUG [bff04de7] I, [2017-07-14T08:43:04.867911 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/sp/application-cc250cd31b4e685c5c3ad102876e9ba5a2b5a08c96a526f29c96b42ae5de21ad.js
DEBUG [bff04de7] I, [2017-07-14T08:43:04.868826 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/sp/application-cc250cd31b4e685c5c3ad102876e9ba5a2b5a08c96a526f29c96b42ae5de21ad.js.gz
DEBUG [bff04de7] I, [2017-07-14T08:43:06.727274 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/pc/application-fbba9862a5ae9d191a0431102450ed122a54155cc81a509bd45e9fb34047b8ce.css
DEBUG [bff04de7] I, [2017-07-14T08:43:06.727790 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/pc/application-fbba9862a5ae9d191a0431102450ed122a54155cc81a509bd45e9fb34047b8ce.css.gz
DEBUG [bff04de7] I, [2017-07-14T08:43:08.232827 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/sp/application-5be34faf9363b508575e153f7a6e0fbcec39e927ded5304754123fe8cf49e221.css
DEBUG [bff04de7] I, [2017-07-14T08:43:08.233346 #17062] INFO -- : Writing /var/www/AppName/releases/20170714084206/public/assets/sp/application-5be34faf9363b508575e153f7a6e0fbcec39e927ded5304754123fe8cf49e221.css.gz
DEBUG [bff04de7] yarn install v0.27.5
DEBUG [bff04de7] warning package.json: No license field
DEBUG [bff04de7] warning No license field
DEBUG [bff04de7] [1/4] Resolving packages...
DEBUG [bff04de7] [2/4] Fetching packages...
DEBUG [bff04de7] warning fsevents@1.1.2: The platform "linux" is incompatible with this module.
DEBUG [bff04de7] info "fsevents@1.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
DEBUG [bff04de7] [3/4] Linking dependencies...
DEBUG [bff04de7] warning "react-dnd-html5-backend@2.4.1" has unmet peer dependency "react-dnd@^2.4.0".
DEBUG [bff04de7] warning "react-moment@0.2.4" has unmet peer dependency "moment-timezone@^0.5.11".
DEBUG [bff04de7] [4/4] Building fresh packages...
DEBUG [bff04de7] Done in 4.91s.
以下是相关文件。
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
require 'capistrano/rails'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/rbenv'
require 'capistrano/bundler'
require "capistrano/yarn"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
# Load custom tasks from `lib/capistrano/tasks' if you have any defined
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
{
"dependencies": {
"babel-loader": "7.x",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.5.2",
"coffee-loader": "^0.7.3",
"coffee-script": "^1.12.6",
"compression-webpack-plugin": "^0.4.0",
"css-loader": "^0.28.4",
"extract-text-webpack-plugin": "^2.1.2",
"file-loader": "^0.11.2",
"glob": "^7.1.2",
"immutability-helper": "^2.2.2",
"jquery": "^3.2.1",
"jquery-ui-sortable-npm": "^1.0.0",
"js-yaml": "^3.8.4",
"moment": "^2.18.1",
"node-sass": "^4.5.3",
"path-complete-extname": "^0.1.0",
"postcss-cssnext": "^2.11.0",
"postcss-loader": "^2.0.5",
"postcss-smart-import": "^0.7.4",
"prop-types": "^15.5.10",
"rails-erb-loader": "^5.0.1",
"react-day-picker": "^5.5.3",
"react-dnd-html5-backend": "^2.4.1",
"react-dropzone": "^3.13.2",
"react-moment": "^0.2.4",
"react-sortable": "^1.2.0",
"resolve-url-loader": "^2.0.2",
"sass-loader": "^6.0.5",
"style-loader": "^0.18.2",
"superagent": "^3.5.2",
"webpack": "^2.6.1",
"webpack-manifest-plugin": "^1.1.0",
"webpack-merge": "^4.1.0"
},
"devDependencies": {
"babel-core": "^6.25.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babelify": "^7.3.0",
"browserify": "^14.4.0",
"browserify-incremental": "^3.1.1",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"webpack-dev-server": "^2.4.5"
}
}
# config valid only for current version of Capistrano
lock '3.8.1'
set :application, 'AppName'
set :repo_url, 'git@github.com:ORG/AppName.git'
set :branch, 'master'
set :deploy_to, '/var/www/AppName'
set :keep_releases, 5
set :rbenv_type, :user
set :rbenv_ruby, '2.4.1'
set :log_level, :debug
rbenv_path = "~/.rbenv/bin/rbenv"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all
set :linked_files, %w{config/database.yml config/settings/production.local.yml}
set :linked_dirs, %w{bin log tmp/backup tmp/pids tmp/cache tmp/sockets vendor/bundle node_modules}
set :default_env, { path: "~/.rbenv/shims:~/.rbenv/bin:$PATH" }
namespace :deploy do
desc 'Restart application'
task :restart do
invoke 'unicorn:restart'
end
desc 'Create database'
task :db_create do
on roles(:db) do |host|
with rails_env: fetch(:rails_env) do
within current_path do
execute :bundle, :exec, :rake, 'db:create'
end
end
end
end
desc 'Run seed'
task :seed do
on roles(:app) do
with rails_env: fetch(:rails_env) do
within current_path do
execute :bundle, :exec, :rake, 'db:seed'
end
end
end
end
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do; end
end
after :finished, :cleanup
end
当我在本地计算机上运行rake assets:precompile RAILS_ENV=production
时,它可以正常工作。
yarn install v0.27.5
warning package.json: No license field
warning No license field
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.69s.
Webpacker is installed
Using /Users/fumiyamizuguchi/Projects/Rails/AppName/config/webpacker.yml file for setting up webpack paths
[Webpacker] Compiling assets
[Webpacker] Compiled digests for all packs in /Users/fumiyamizuguchi/Projects/Rails/AppName/app/javascript/packs:
{"application.js"=>"/packs/application.js", "calendar.js"=>"/packs/calendar.js", "favorite_box.js"=>"/packs/favorite_box.js", "messenger.js"=>"/packs/messenger.js", "room_images.js"=>"/packs/room_images.js"}
请给我建议解决这个问题。谢谢。