create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

The npm start command is too slow

Open tymsai opened this issue 4 years ago • 34 comments

Current Behavior The npm start command is too slow it takes almost 5 min to start

Expected Behavior It was expected to start within some seconds

Steps To Reproduce type npm start and hit enter in Power Shell Terminal

Environment windows 10 home node latest version npm latest

tymsai avatar Jun 22 '21 05:06 tymsai

30 seconds is a normal startup time. it might be an older version of webpack and babel issue. In window 10 I believe it will always take a bit longer time to load. it would not worry about it too much.

vikky-10 avatar Jun 22 '21 07:06 vikky-10

npm start took exact 8 min to start react app

tymsai avatar Jun 22 '21 09:06 tymsai

echo hello is fast

tymsai avatar Jun 23 '21 03:06 tymsai

anybody know how to resolve this ?????

tymsai avatar Jun 24 '21 15:06 tymsai

try Linux and fuck NTFS will resolve it

ShellWen avatar Jun 25 '21 04:06 ShellWen

i have same problem can any one help me out? thanks in advance

Jacsonrai avatar Sep 22 '21 14:09 Jacsonrai

As the project becomes larger and larger, I also encountered this problem. Recently, I used esbuild to improve the speed of the development mode. You can try the integration, which greatly improves the efficiency of the development mode.

npm i react-app-rewired-esbuild -D

fupengl avatar Oct 14 '21 15:10 fupengl

okay

tymsai avatar Oct 15 '21 01:10 tymsai

you should try yarn instead of npm. yarn is faster

Current Behavior The npm start command is too slow it takes almost 5 min to start

Expected Behavior It was expected to start within some seconds

Steps To Reproduce type npm start and hit enter in Power Shell Terminal

Environment windows 10 home node latest version npm latest

Try yarn instead of npm. Yarn is fatster

Ultra-Tech-code avatar Nov 16 '21 16:11 Ultra-Tech-code

Thanks

tymsai avatar Nov 19 '21 02:11 tymsai

@Ultra-Tech-code Sorry but I don't get your point. Yarn may be faster for the resolution of the packages, but here we are just talking about starting the development server of the React app. Correct me if I am wrong but it does not change anything to use yarn or npm to start the app from the startup time point of view.

Amatewasu avatar Nov 19 '21 08:11 Amatewasu

Since Webpack 5 prints its bundling time, it looks like that most of the time spent by react-scripts to start comes from Webpack. I would say that using other bundlers such as Parcel or Vite would help on this issue but it looks like it's far from easy to migrate.

Amatewasu avatar Dec 14 '21 17:12 Amatewasu

try Linux and fuck NTFS will resolve it

try WinAPIs and fuck Unix and Unix Clones and EXT4/ZFS to death will resolve it

ghost avatar Mar 02 '22 15:03 ghost

I am facing the same problem :)

ibnTofajjal avatar Jun 27 '22 06:06 ibnTofajjal

I am facing the same problem :)

You can use esbuild to speed up, but it will cause fast_refresh to fail Need to keep fast_refresh can use swc to improve speed It is recommended to speed up as a development mode, and it is not recommended to use it in a production environment

fupengl avatar Jun 27 '22 06:06 fupengl

I am facing the same problem :)

@ibntofajjal , you can use WSL2 and install your project in Linux's subsystem because dependencies from react server, storybook server, nodemon and others work better in a Linux environment. The steps are:

  • Install and configure WSL2, for example, go to: https://pureinfotech.com/install-windows-subsystem-linux-2-windows-10/
  • Install your project in the Linux subsystem(go to WSL prompt)
    • Go to a directory that you want to install (for example: cd /home/yourusername/projects)
    • And install your react project with git clone yourproject
  • After it, you go to root folder of your project: cd yourproject
  • Use the below commands:
    • npm install
    • npm start
  • And enjoy!

matheusfcorocher avatar Jul 15 '22 01:07 matheusfcorocher

@matheusfcorocher Did you notice a noticeable performance improvement? It would be so nice if you could provide a small benchmark. :)

Amatewasu avatar Jul 15 '22 08:07 Amatewasu

@matheusfcorocher Did you notice a noticeable performance improvement? It would be so nice if you could provide a small benchmark. :)

@Amatewasu, yes my build time was 1.49min(109 s) when the project is in Windows filesystem. And when the project is in Linux filesystem, the build time was 15 s. So, my build time got 7.2x faster. But in both cases I was using a WSL terminal, so my solution could be misleading because my npm package was in Linux subsystem, so the time he needs to transverse until reached project folder in Windows filesystem is greater than if a project is in WSL filesystem.

matheusfcorocher avatar Jul 15 '22 12:07 matheusfcorocher

@matheusfcorocher Did you notice a noticeable performance improvement? It would be so nice if you could provide a small benchmark. :)

@Amatewasu, yes my build time was 1.49min(109 s) when the project is in Windows filesystem. And when the project is in Linux filesystem, the build time was 15 s. So, my build time got 7.2x faster. But in both cases I was using a WSL terminal, so my solution could be misleading because my npm package was in Linux subsystem, so the time he needs to transverse until reached project folder in Windows filesystem is greater than if a project is in WSL filesystem.

Oh great tip, I will try, thanks a lot!

Amatewasu avatar Jul 15 '22 12:07 Amatewasu

npm start took exact 8 min to start react app

After more than a year it is still taking 8 minutes, wow?!

I read your solutions about using WSL 2, but it has unfixed bug where it takes up all (99%) of your RAM, unless you shut it down and start again. And low RAM is not the issue ... I can't recall the forum where a person had the same issue with 64GB of RAM and the solution was: Yeah it's a known issue.

NOTE: I just googled to see if I was perhaps using WSL version 1, but google's first result:

After upgrade to WSL2, Vmmem almost occupy 100% RAM and CPU, and it don't work with below solution: .wslconfig

So my personal solution for Windows OS:

  1. npm start
  2. Watch cars videos for 8mins.
  3. Code

Aleksandar15 avatar Jul 31 '22 20:07 Aleksandar15

That's interesting.

I created a simple create-react-app project. On my WSL2, npm install took about 1.5 min and npm start took about 4 min. On my powershell environment, npm install took about 15 sec and npm start took about 30 sec.

I'm surprised people are having better performance on WSL.

MichaelSalSail avatar Aug 09 '22 12:08 MichaelSalSail

I prefer to use vite.js

ibnTofajjal avatar Aug 10 '22 06:08 ibnTofajjal

I dont know if this is still relevant but I fixed this issue by executing commande npm i

artiomsinigur avatar Nov 06 '22 03:11 artiomsinigur

Has anyone discovered a solution that effectively addresses this problem? Despite trying using a different web browser (Edge) instead of Chrome, the issue still persists and it is becoming increasingly frustrating.

punjabinuclei avatar Feb 08 '23 17:02 punjabinuclei

use vite and yarn for react

ibnTofajjal avatar Feb 11 '23 12:02 ibnTofajjal

Hello, I get the same issue !

Devlewi avatar Feb 22 '23 14:02 Devlewi

Hello, I get the same issue !

use https://vitejs.dev/

or Yarn

ibnTofajjal avatar Feb 22 '23 15:02 ibnTofajjal

use npm i

HEMANTH123SR avatar Mar 18 '23 04:03 HEMANTH123SR

I am still learning React and I used the command npm start and it took more than 7 minutes to start the development server. Using Linux Mint 20.04. My project is reall small only has 4 small components.

When I run php artisan serve to run my PHP projects it takes about 30 seconds to start.

tiagoskaterock avatar May 07 '23 23:05 tiagoskaterock

I was using WSL to access my hard drive on the Windows Filesystem. I can confirm that when I moved the project to the same drive as WSL, the project loaded in 3.8 seconds, compared to 5 minutes on the Windows filesystem. I highly recommend keeping your projects on the same drive as WSL.

gustavobraga98 avatar Sep 28 '23 14:09 gustavobraga98