Webpack taking too long?

Webpack taking too long?
0

#1

I am wondering why is taking so long for webpack to run?
The last build it was: 141808ms … that’s almost 142 seconds o.O , insane, right?
My app is a very simple react app (just learning it :slight_smile: ), just 1 main component with 2 simple components within it.
I have all the code on github.


#2

By webkit you mean webpack?


#3

Silly me xD… I’ve modified! Thanks!


#4

One second for me. Try to delete node_modules folder and run npm i to reinstall.


#5

Not working… :disappointed_relieved: still taking a lot of time… 44 seconds…


#6

How are you running it?


#7

In my terminal I’m running: webpack command. Same as you do!


#8

Try this, in your package.json:

{
  "name": "react-tutorials",
  "version": "0.0.1",
  "description": "Learning react",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "webpack": "webpack"  <--- add this line
  },
...

And in your terminal run npm run webpack


#9

Interesting… it is now taking 5 seconds… Why was that huge before?

EDIT: now with webpack commad is also taking < 5 seconds…


#10

I guess you have installed webpack globally. And who knows what it was compiling. Maybe all the .js and .jsx files on your computer.

Rule of thumb: don’t install anything globally.


#11

Hmm… Yes I did. :thinking: Why wouldn’t I install things globally?
Also, it if is that wrong, how can I remove them?


#12

#13

To remove I think npm uninstall webpack -g should work.


#14

I removed it from -g, and I am using npm run webpack and now it takes again around 40 seconds :expressionless:… It’s annoying when you want to fix some errors and you have to compile everytime…
Any advice on how could I go around this?


#15

Hard to say. Problem is not in your code. If you are on Windows I can only recommend to restart your pc (I know sounds silly :slight_smile: )

Also check your Node and npm versions.

node -v
npm -v

#16

node : 4.5.0
npm: 2.15.9

I am running on a mac. I checked the Activity Monitor and everything looks fine. :expressionless:


#17

Looks very old.

Latest node: 7.2.1
Latest npm: 4.0.3


#18

Is there a command to upgrade them? :slight_smile:


#19

I usually use:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

I’m on linux, but this should work same on mac.


#20

Thank you.

I have now node: 7.2.1 but npm only 3.10.10 :slight_smile: