ELIFECYCLE errorno 1 when deploying to production - javascript

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.

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.

Related

a complete log of this run can be found in npm run dev - ubuntu

Good morning, I am trying to make a deployment of a page developed in vue.js and I uploaded all the files and it works, I just need to run "npm run dev" but it throws me the following error. I already ran "npm install" delete package.json and the node_modules folders I ran everything from scratch again but it remains the same
> # dev /var/www/html
> npm run development
> # development /var/www/html
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js
21% building 95/96 modules 1 active .../dist/cjs.js??ref--5-5!/var/www/html/resources/sass/app.scssnpm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # development 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! /root/.npm/_logs/2021-01-08T16_00_32_214Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev 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! /root/.npm/_logs/2021-01-08T16_00_32_256Z-debug.log
Try to below way i hope it work
1. cmd -> npm cache clean
2. delete package.lock.json file
3. delete node module folder
4. cmd -> npm install

ENOENT: no such file or directory, open '/tmp/build_01409f5f7cae8788b3a2ccca28c521d8/client/package.json'

I'm trying to do a production build on Heroku of a udemy course React project. I've tried so many things to make it work but I'm completely at a loss.
The output from the Heroku build process:
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): 12.17.0
engines.npm (package.json): 6.14.5
Resolving node version 12.17.0...
Downloading and installing node 12.17.0...
Bootstrapping npm 6.14.5 (replacing 6.14.4)...
npm 6.14.5 installed
-----> Restoring cache
Cached directories were not restored due to a change in version of node, npm, yarn or stack
Module installation may take longer for this build
-----> Installing dependencies
Installing node modules (package.json)
> nodemon#2.0.4 postinstall /tmp/build_01409f5f7cae8788b3a2ccca28c521d8/node_modules/nodemon
> node bin/postinstall || exit 0
Love nodemon? You can now support the project via the open collective:
> https://opencollective.com/nodemon/donate
added 267 packages from 183 contributors and audited 268 packages in 11.725s
12 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
-----> Build
Running heroku-postbuild
> server#1.0.0 heroku-postbuild /tmp/build_01409f5f7cae8788b3a2ccca28c521d8
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
up to date in 0.618s
found 0 vulnerabilities
npm ERR! code ENOENT npm ERR! syscall open npm ERR! path /tmp/build_01409f5f7cae8788b3a2ccca28c521d8/client/package.json npm
ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory, open
'/tmp/build_01409f5f7cae8788b3a2ccca28c521d8/client/package.json' npm
ERR! enoent This is related to npm not being able to find a file. npm
ERR! enoent npm ERR! A complete log of this run can be found in: npm
ERR! /tmp/npmcache.h4E00/_logs/2020-05-27T18_18_35_286Z-debug.log
npm ERR! code ELIFECYCLE npm ERR! errno 254 npm ERR! server#1.0.0
heroku-postbuild: NPM_CONFIG_PRODUCTION=false npm install --prefix
client && npm run build --prefix client npm ERR! Exit status 254 npm
ERR! npm ERR! Failed at the server#1.0.0 heroku-postbuild 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!
/tmp/npmcache.h4E00/_logs/2020-05-27T18_18_35_303Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app. ! Push failed
From the server index.js:
if (process.env.NODE_ENV === 'production') {
// Express will serve production assets
app.use(express.static('client/build'));
// Express will serve index.html file if it doesn't recognise the route
const path = require('path');
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'client', 'build', "index.html"));
});
}
The server package.json:
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"engines": {
"node": "12.17.0",
"npm": "6.14.5"
},
"scripts": {
"start": "node index.js",
"server": "nodemon index.js",
"client": "npm run start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"concurrently": "^5.2.0",
"cookie-session": "^1.4.0",
"express": "^4.17.1",
"mongoose": "^5.9.15",
"nodemon": "^2.0.4",
"passport": "^0.4.1",
"passport-google-oauth20": "^2.0.0",
"stripe": "^8.55.0"
}
}
.gitignore:
node_modules
dev.js
It turns out that because I hadn't deleted the .git created by create-react-app in my /client directory, this was stopping the /server repository including the front-end files. So just had to delete this and reinitialise the /server git repository.
You have to delete .git file that created by create-react-app
try this:
first in main app folder delete .git file watch out for hiden folders
then go to client and search for .git in there if there was any delete it
in terminal go to your project folder and type git init
then follow the steps that tells you on your heroku main dashboard page

NPM scripts permission denied on chronos (chromebook shell)

I recently installed node on my chromebook. I have git cloned a basic node repo that is trying to run things like webpack, babel-node, and concurrently through npm scripts.
However, running webpack (in the same directory) works just fine.
I have run "sudo chmod -R 777 my_app" and it did not help.
Here is the error message:
chronos#localhost ~/Downloads/MODULE $ npm start
> my-glitch-app#0.0.1 start /home/chronos/user/Downloads/MODULE
> concurrently "webpack -w -p" "babel-node server.js"
sh: concurrently: Permission denied
npm ERR! Linux 3.18.0-14875-g438cb8ab27c6
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! my-glitch-app#0.0.1 start: `concurrently "webpack -w -p" "babel-node server.js"`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the my-glitch-app#0.0.1 start script 'concurrently "webpack -w -p" "babel-node server.js"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the my-glitch-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! concurrently "webpack -w -p" "babel-node server.js"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs my-glitch-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls my-glitch-app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/chronos/user/Downloads/MODULE/npm-debug.log
following my comment above, sudo mount -o remount,exec /home/chronos/user seemed to work, but i have further anomalies in my case, so i'd be curious about peer experience

npm caching issue- did not rebuild

I'm using Laravel 5.4 with vue.js . Then i had syntax error between created and methods. I forgot , then i fix this error.
But still the error continue.
<script>
export default {
data(){
return {
users: []
}
},
created(){
this.fetchUsers();
},//forgotten
methods:{ //41.line
fetchUsers(){
this.$http.get('/users').then(response => {
this.users = response.data.users;
});
}
}
}
</script>
I was restarted apache.But still have this error if i write "npm run dev" or "npm run watch".
error in ./resources/assets/js/components/Users.vue
Syntax Error: Unexpected token, expected , (41:4)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! # development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the # development 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/ubuntu/.npm/_logs/2017-07-11T08_13_41_572Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! # dev: `npm run development`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the # dev 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/ubuntu/.npm/_logs/2017-07-11T08_13_41_618Z-debug.log
EDIT
I listen your advice and applied.I mean the problem is not relevant syntax mistake.The problem is old code execute insead of new code.I saved all file and then "npm run dev" but return same error everytime.
Even I got the same error- A complete log of this run can be found in:
The problem is with the port number, go to package.json file and change the port number to anything you want, say 8000. For example:
"scripts": {
"build": "webpack --config webpack.prod.js --progress",
"watch": "npm run build -- --watch",
"server": "webpack-dev-server --inline --progress --port 8000 --content-base src",
"start": "npm run server"
}
Earlier the port number was 3000, and on npm start different application use to render on port 3000 so for my new application I gave port number 8000. Now I can have two different application on different ports (localhost:3000 and localhost:8000) without getting error.

'NODE_ENV' is not recognized as an internal or external command

I have an app which is working perfectly on linux but when I execute it on windows I get this error.
'NODE_ENV' is not recognized as an internal or external command,
operable program or batch file.
'NODE_ENV' is not recognized as an internal or external command,operable program or batch file.
npm
ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! aaa#1.0.0 webpack-watch: `NODE_ENV='debug' webpack --progress -d -colors --watch`
npm ERR! Exit status 1
npm ERR!
I have tried this in cmd.
SET NODE_ENV=debug
which I found here “NODE_ENV” is not recognized as an internal or external command
And here is snippet of code package.json where I guess is my mistake.
"webpack-watch": "NODE_ENV='debug' webpack --progress -d --colors --watch",
"server-watch": "NODE_ENV='debug' nodemon backend/server.js"
Windows doesn't understand the syntax var=value cmd1 arg1. You need to adapt the NPM run tasks to use Windows' syntax:
"webpack-watch-win": "set NODE_ENV=debug & webpack ..."
"server-watch-win": "set NODE_ENV=debug & nodemon ..."
....but there are probably more errors you will hit downstream. This should at least get you past the environment variable declaration, though. Node is strongly rooted in *nix shells, not cmd.exe.
Setup your NODE_ENV with export. So in your package.json add in your scripts block
"scripts":{
"webpack-watch": "export NODE_ENV='debug' && webpack --progress -d --colors --watch",
"server-watch": "export NODE_ENV='debug' && nodemon backend/server.js"
}

Categories

Resources