I am deploying my app to amazon ec2 with bundle exec cap production deploy command. after doing so I am getting this error.
** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:
INFO The Gemfile's dependencies are satisfied, skipping installation
DEBUG [9f517820] Running if test ! -d /var/www/my-app/releases/20230824101706; then echo "Directory does not exist '/var/www/my-app/releases/20230824101706'" 1>&2; false; fi as [email protected]
DEBUG [9f517820] Command: if test ! -d /var/www/my-app/releases/20230824101706; then echo "Directory does not exist '/var/www/my-app/releases/20230824101706'" 1>&2; false; fi
DEBUG [9f517820] Finished in 0.872 seconds with exit status 0 (successful).
INFO [b269c8da] Running /usr/local/rvm/bin/rvm 3.0.0 do bundle exec rake assets:precompile as [email protected]
DEBUG [b269c8da] Command: cd /var/www/my-app/releases/20230824101706 && ( export RAILS_ENV="production" RAILS_GROUPS="" ; /usr/local/rvm/bin/rvm 3.0.0 do bundle exec rake assets:precompile )
DEBUG [b269c8da] yarn install v1.22.19
DEBUG [b269c8da] warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
DEBUG [b269c8da] [1/5] Validating package.json...
DEBUG [b269c8da] error [email protected]: The engine "node" is incompatible with this module. Expected version "14.21.3". Got "12.22.9"
DEBUG [b269c8da] error Found incompatible module.
DEBUG [b269c8da] info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
DEBUG [b269c8da] rake aborted!
cssbundling-rails: Command css:build failed, ensure yarn is installed and `yarn build:css` runs without errors or use SKIP_CSS_BUILD env variable
/var/www/my-app/shared/bundle/ruby/3.0.0/gems/cssbundling-rails-1.2.0/lib/tasks/cssbundling/build.rake:5:in `block (2 levels) in <main>'
/var/www/my-app/shared/bundle/ruby/3.0.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-3.0.0/bin/ruby_executable_hooks:22:in `eval'
/usr/local/rvm/gems/ruby-3.0.0/bin/ruby_executable_hooks:22:in `<main>'
Tasks: TOP => assets:precompile => css:build
(See full trace by running task with --trace)
this is asking me to update my node version to the latest one I did so wth of
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 14.21.3
nvm use 14.21.3
I can see my node version as 14.21.3
developer@azhar:~/BFGL/my-app$ node -v
v14.16.0
but when I again start deploying my project I am getting the same error with incompatible node version.
I tried doing multiple solution from web, like deleting my package.lock.json, yarn.lock and node modules form my local system and generating them again with yarn install --ignore-engines command and again pushed them to my repository.
I even tried defining my node version explicitly on my package.json file and pushed to repository.
},
"engines": {
"node": "14.21.3"
}
After trying multiple solutions I am not getting anywhere I am in need of some help here.
This error looks somewhat familar.
Firstly, only use either yarn or npm and remove the lockfile for the package manager you do not use.
From the command you ran to upgrade npm, it seems like you're running that one on your dev machine? Just going off the hostname from your snippet. If that is the case, then you're running it on the wrong machine. You'll need to ssh to the ec2 instance and run commands on that.
When you ssh to the server, check the node version, yarn version and install/upgrade if necessary, and try again.