0

I'm trying to deploy a Laravel project to my server with this specs:

  • OS: CentOS Linux release 7.8.2003
  • Nodejs: 13.14.0
  • npm: 6.14.5
  • 1 CPU
  • 4GB Ram

Everything was fine but a step, as I use ReactJS with Laravel I have to run npm run dev to let webpack build my assets files. (This is just the step to build the view, it run fine on my local machine and my friend's, with the different of os, MacOS and Ubuntu).

But when I run npm run dev the system either hang like this

[spyets@vultr current]$ npm run dev

> @ dev /home/spyets/public_html/yamlive/releases/3
> npm run development


> @ development /home/spyets/public_html/yamlive/releases/3
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

enter image description here

or show this error

Exit Code: 254 (Unknown error)                                                    

  Host Name: development                                                            

  ================                                                                  
  bash: fork: retry: No child processes                                             
  bash: fork: retry: No child processes                                             
  bash: fork: retry: No child processes                                             
  bash: fork: retry: No child processes                                             
  bash: fork: Resource temporarily unavailable 

enter image description here

I don't know if this give you more information, I run a vtop (a terminal management tool?) and every time I run the npm run dev command, vtop just crashed

What I tried:

  1. reboot the server
  2. reinstall nodejs ( I install nodejs directly with yum not using nvm )
  3. upgrade nodejs from 12.20.2 to 13.14.0 ( as it currently in 13.14.0 )

I'm new to Centos and deployment.

Edit

  • I also tried to make swapfile and add 3GB of swap
  • I tried remove node_modules and reinstall with npm install multiple times
  • Running both npm run dev and npm run prod resulted in failed or crash
halfer
  • 18,701
  • 13
  • 79
  • 158
Brody
  • 13
  • 5
  • Why do you want to run `npm run dev` if you are trying to deploy? it should be `npm run production`, also did you run `npm install`? – Remul Jun 02 '20 at 09:01
  • Ahh yes, I just run `npm run dev` to debug, I did run `npm run prod`. I am pretty sure that i already run `npm install`, I also try to remove node_modules and run `npm install` again – Brody Jun 02 '20 at 09:44

2 Answers2

0

Just 2 days back I was facing the same problem when running npm run prod. The command would start and then after 2 mins it would terminate, leaving me with nothing.

Then I came across Swap Memory. I followed this answer How do you add swap to an EC2 instance? and added a swap memory to my hosting server.

Here are the steps:

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo chmod 600 /var/swap.1
sudo /sbin/swapon /var/swap.1

To confirm this, run htop and you will see Swp [|||| 0K/1.00G]

I still recommend going through the post to understand this better.

Digvijay
  • 4,163
  • 2
  • 14
  • 36
  • Yes thanks you for point me to this, I already try to add swapfile, I don't think this is the problem with my Memory since there is 4GB of RAM and I also add 3GB more. the problem still persists – Brody Jun 02 '20 at 09:28
0

After a lot of google and inspects, I found out that my system user ( ssh user ) have been create with limited access to the os resources.

My user config file was located in /etc/security/limits.d/example_user.conf

example_user soft nproc 40
example_user hard nproc 40
example_user soft nofile 150
example_user hard nofile 150

My Solution:

I backed up the file, deleted it in the /etc/security/limits.d/ directory and reboot the system.

The npm command successfully running now.

I read this document to find out about the error.

limits.d configuration document

Brody
  • 13
  • 5