Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

javascript - ELIFECYCLE errorno 1 when deploying to production

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 [email protected] '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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In case that anyone is just going through the same and checked every other alternatives here, it was a server memory problem. We just had to clean it and we were ready to keep it going. Apparently after several deploys it ran out of space.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...