I'm stucked with this problem and I need to fix it already so any tips will be truly appreciated.
I've my project made with Laravel and Vue, with an image container in Docker. The app is hosted in AWS.
The problem I'm facing is that I can't deploy the app to production using the follow command: ssh ec2-user@13.58.231.51 'cd /var/www/mevym/; ./deploy.sh'
The curious part is that if I run npm run production
it works perfectly fine.
I already tried every single solutions from similar threads, like this one: How to solve npm error "npm ERR! code ELIFECYCLE" but nothing worked for me.
This is my package.json:
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --config=node_modules/laravel-mix/setup/webpack.config.js"
},
Just in case, here it's my webpack.mix.js:
mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
require('postcss-import'),
require('tailwindcss'),
])
.webpackConfig(require('./webpack.config'));
.deploy.sh:
# Enter maintenance mode
(php artisan down --message 'The app is being (quickly!) updated. Please try again in a minute.') || true
# Update branch
git fetch --all
git reset --hard origin/main
# Make storage writable
sudo chmod -R 777 ./storage
# Install dependencies based on lock file
composer install --no-interaction --prefer-dist --optimize-autoloader
# JS dependencies
npm install
# Migrate database
php artisan migrate --force
# Compile assets
npm run prod
# Clear cache
php artisan optimize
# Reload PHP to update opcache
echo "" | sudo -S service php-fpm reload
# Exit maintenance mode
php artisan up
echo "Application deployed!"
And finally the error:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ec2-user/.npm/_logs/2021-01-08T18_49_06_563Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ prod: `npm run production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Thanks in advance.