facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.72k stars 26.85k forks source link

The npm start command is too slow #11133

Open tymsai opened 3 years ago

tymsai commented 3 years ago

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

vikky-10 commented 3 years ago

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.

tymsai commented 3 years ago

npm start took exact 8 min to start react app

tymsai commented 3 years ago

echo hello is fast

tymsai commented 3 years ago

anybody know how to resolve this ?????

ShellWen commented 3 years ago

try Linux and fuck NTFS will resolve it

Jacsonrai commented 3 years ago

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

fupengl commented 3 years ago

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
tymsai commented 3 years ago

okay

Ultra-Tech-code commented 2 years ago

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

tymsai commented 2 years ago

Thanks

Amatewasu commented 2 years ago

@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 commented 2 years ago

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.

ghost commented 2 years ago

try Linux and fuck NTFS will resolve it

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

ibnTofajjal commented 2 years ago

I am facing the same problem :)

fupengl commented 2 years ago

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

matheusfcorocher commented 2 years ago

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:

Amatewasu commented 2 years ago

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

matheusfcorocher commented 2 years ago

@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.

Amatewasu commented 2 years ago

@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!

Aleksandar15 commented 2 years ago

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
MichaelSalSail commented 2 years ago

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.

ibnTofajjal commented 2 years ago

I prefer to use vite.js

artiomsinigur commented 1 year ago

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

punjabinuclei commented 1 year ago

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.

ibnTofajjal commented 1 year ago

use vite and yarn for react

Devlewi commented 1 year ago

Hello, I get the same issue !

ibnTofajjal commented 1 year ago

Hello, I get the same issue !

use https://vitejs.dev/

or Yarn

HEMANTH123SR commented 1 year ago

use npm i

tiagoskaterock commented 1 year ago

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.

gustavobraga98 commented 1 year ago

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.

tymsai commented 1 year ago

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.

yea

saurabhkhadsang commented 10 months ago

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

Use Git Bash – it worked for me. Windows PowerShell took 7-10 minutes, but with Git Bash, it's down to just 10 seconds!

hamzash10 commented 2 months ago

im facing the same problem, im on vscode using wsl it was working fine but suddenly it started taking too long to start, i dont know why, any help is appreciated.

ibnTofajjal commented 2 months ago

use vite