#reactjs #ubuntu #capistrano3
#reactjs #ubuntu #capistrano3
Вопрос:
Я пытаюсь развернуть приложение react, созданное с помощью create-react-app, и использую Capistrano для развертывания и Ubuntu server в AWS в качестве сервера.
Версии — Capistrano: 3.15 Реакция: 17.0.1
Я получаю следующую ошибку при развертывании на сервере экземпляра AWS ec2 ubuntu,
.
.
.
00:29 npm:install
01 /tmp/shopping/nvm-exec.sh npm install --silent --no-progress
01 Now using node v15.5.1 (npm v6.14.11)
01
01 audited 2210 packages in 48.746s
01
01
01 3 packages are looking for funding
01
01 run `npm fund` for details
01
01
01 found 0 vulnerabilities
01
01
✔ 01 ubuntu@IP_ADDR 51.633s
01:21 deploy:npm_deploy
01 build
01 /usr/bin/env:
01 ‘build’
01 : No such file or directory
01
stdout: /usr/bin/env: ‘build’: No such file or directory
stderr: Nothing written
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as ubuntu@IP_ADDR: exit status: 127
stdout: /usr/bin/env: ‘build’: No such file or directory
stderr: Nothing written
Caused by:
SSHKit::Command::Failed: exit status: 127
stdout: /usr/bin/env: ‘build’: No such file or directory
stderr: Nothing written
Tasks: TOP => deploy:symlink:release => deploy:npm_deploy
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as ubuntu@IP_ADDR: exit status: 127
stdout: /usr/bin/env: ‘build’: No such file or directory
stderr: Nothing written
** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:
DEBUG [6caec9a2]
DEBUG [6caec9a2]
DEBUG [6caec9a2] 3 packages are looking for funding
DEBUG [6caec9a2]
DEBUG [6caec9a2] run `npm fund` for details
DEBUG [6caec9a2]
DEBUG [6caec9a2]
DEBUG [6caec9a2] found 0 vulnerabilities
DEBUG [6caec9a2]
DEBUG [6caec9a2]
INFO [6caec9a2] Finished in 51.633 seconds with exit status 0 (successful).
DEBUG [141e7887] Running if test ! -d ~/projects/shopping/staging/releases/20210125100109; then echo "Directory does not exist '~/projects/shopping/staging/releases/20210125100109'" 1>amp;2; false; fi as ubuntu@IP_ADDR
DEBUG [141e7887] Command: if test ! -d ~/projects/shopping/staging/releases/20210125100109; then echo "Directory does not exist '~/projects/shopping/staging/releases/20210125100109'" 1>amp;2; false; fi
DEBUG [141e7887] Finished in 0.602 seconds with exit status 0 (successful).
INFO [7e4d0fd0] Running /usr/bin/env build as ubuntu@IP_ADDR
DEBUG [7e4d0fd0] Command: cd ~/projects/shopping/staging/releases/20210125100109 amp;amp; ( export NODE_VERSION="v15.5.1" ; /usr/bin/env build )
DEBUG [7e4d0fd0] /usr/bin/env:
DEBUG [7e4d0fd0] ‘build’
DEBUG [7e4d0fd0] : No such file or directory
DEBUG [7e4d0fd0]
Вот мой код,
Gemfile
source 'https://rubygems.org'
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
group :development do
gem 'capistrano'
gem 'capistrano-nvm', require: false
gem 'capistrano-npm'
end
Capfile
require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require "capistrano/nvm"
require "capistrano/npm"
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
deploy.rb
append :linked_files, ".env"
append :linked_dirs, "node_modules"
set :nvm_type, :user
set :nvm_node, "v15.5.1"
set :nvm_map_bins, %w{node npm yarn}
set :npm_flags, %w{--silent --no-progress}
namespace :deploy do
task :npm_deploy do
on roles(:app) do
within fetch(:npm_target_path, release_path) do
execute fetch(:npm_bin), "build"
# execute "react-scripts build"
end
end
end
before "symlink:release", :npm_deploy
end
set :keep_releases, 3
Комментарии:
1.
‘build’ DEBUG [7e4d0fd0] : No such file or directory
Есть ли каталог с именемbuild
?2. Я могу запустить команду «npm run build» с сервера и из корня приложения
3. @ShivamJha на самом деле я запускаю задачу «npm_deploy», и в ней у меня есть команда «build»