why does 'npm run build' take >30 minutes on development server and less than a minute locally?
Asked Answered
O

4

6

I am not particularly experienced with either npm or webpack. I have a fairly small project that builds very quickly locally (much less than a minute), yet takes a ridiculously-long time to run on our test server.

in package.json the code is "scripts": { "build": "webpack --config webpack.prod.js", ...

Running npm run build executes very quickly on my local development machine. It uses copy-webpack-plugin as described here to build a directory of static content.

When I attempt to do the same from our test server (after getting exact same files from github), the npm run build command takes well more than half an hour - if it completes at all before I give up and just manually copy over the relevant files from my local dev.

Oaxaca answered 3/6, 2019 at 16:12 Comment(4)
Is your test server internally maintained or do you use a cloud service? It's very hard to pinpoint your precise issue without more information and details of the test server but one suggestion could be that your tests are being queued and the server is under an insurmountable load at the moment.Higbee
You are correct that there are quite a few possibilities and that I didn't give a lot of details. I wasn't sure what would be helpful and what would be just noise. Our server is on an EC2 instance with aws. it's a micro instance, and I'm not expecting world-beating performance, but I am surprised at the utter lack of performance. (if there is load on the server, it is unrelated to our site, as it has very little traffic as of yet)Oaxaca
@susiederkins What about the performance of the npm install / npm ci command?Upsweep
@Upsweep npm install is also brutally slow on the server (but perfectly quick on my development machine). The last time I ran it it seemed to hang - I killed it and then ran npm install --verbose, which worked as quickly as running locally does. I am not familiar with npm ci but will look into it.Oaxaca
S
7

In my case it appears to have been because my Digital Ocean droplet was limited on RAM and/or CPU and my MySQL server was using a fair chunk of that.

The fix for me was to stop MySQL before running npm install or npm run build:

sudo systemctl stop mysql
sudo npm run build --emptyOutDir
sudo systemctl start mysql
Strike answered 18/8, 2023 at 3:23 Comment(0)
D
0

may be you are using a latest version 8.x.0 on the build agent. Downgrade to the latest long term support version 6.11.x, it may resolve the issue.

Destitution answered 5/8, 2022 at 17:16 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Kalmick
B
0

I used npm cache clean —force in /client root folder (where you have package.json) and I realized that I hadn’t stopped my hosting service, so I stopped it with pm2 stop index.js. My hosting service was Index.js in /server.

Baez answered 13/3, 2023 at 1:44 Comment(1)
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From ReviewBusywork
E
0

Try deleting your node_modules folder, and then do npm i . After this try doing npm run build again.

Enforcement answered 18/11, 2023 at 8:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.