siddharthkp / cost-of-modules

Find out which of your dependencies are slowing you down 🐢
MIT License
2.84k stars 41 forks source link

Windows - Size returned in NaNM for all packages #23

Closed rayno closed 7 years ago

rayno commented 8 years ago

Just tried it today on Your OS is Windows 10 64-bit

cost-of-modules --no-install --less

Calculating...

┌─────────────────────────────┬──────────────┬───────┐
│ name                        │ children     │ size  │
├─────────────────────────────┼──────────────┼───────┤
│ react-datepicker            │ 4            │ NaNM  │
├─────────────────────────────┼──────────────┼───────┤
│ sticky-table-headers        │ 0            │ NaNM  │
├─────────────────────────────┼──────────────┼───────┤
│ d3                          │ 0            │ NaNM  │
├─────────────────────────────┼──────────────┼───────┤
│ envify                      │ 21           │ NaNM  │
├─────────────────────────────┼──────────────┼───────┤
│ extract-text-webpack-plugin │ 9            │ NaNM  │
├─────────────────────────────┼──────────────┼───────┤
│ flux-standard-action        │ 5            │ NaNM  │
├─────────────────────────────┼──────────────┼───────┤
│ history                     │ 5            │ NaNM  │
├─────────────────────────────┼──────────────┼───────┤
│ http-server                 │ 19           │ NaNM  │
├─────────────────────────────┼──────────────┼───────┤
│ keypress.js                 │ 0            │ NaNM  │
├─────────────────────────────┼──────────────┼───────┤
│ lodash                      │ 0            │ NaNM  │
├─────────────────────────────┼──────────────┼───────┤
│ + 26 modules                │              │       │
├─────────────────────────────┼──────────────┼───────┤
│ 36 modules                  │ 238 children │ 0.00M │
└─────────────────────────────┴──────────────┴───────┘
siddharthkp commented 8 years ago

@rayno Honestly, I have not tested on windows!

Can you give me the output of du --max-depth 1 -k --exclude ".*" node_modules in your root directory? That will help.

rayno commented 8 years ago

Here you are! debug.txt

siddharthkp commented 8 years ago

@rayno That looks, perfectly fine. Not sure what's wrong :thinking:

I'll get my hands on a windows machine and debug soon

siddharthkp commented 8 years ago

@rayno, Can you help me debug this?

Please clone the repo and run npm test

rayno commented 8 years ago

Hi again,

When running the tests the linting fails because of line endings. After removing the lint the tests are not able to run

Output from WebStorm:

npm test

> npm run build && npm run ava

> cost-of-modules@0.4.1 build D:\Projects\cost-of-modules
> babel src -d lib && babel test/src -d test/lib

src\helpers.js -> lib\helpers.js
src\index.js -> lib\index.js
test\src\0prod.js -> test\lib\0prod.js
test\src\1dev.js -> test\lib\1dev.js
test\src\fixtures\dev-test-data.js -> test\lib\fixtures\dev-test-data.js
test\src\fixtures\helpers.js -> test\lib\fixtures\helpers.js
test\src\fixtures\test-data.js -> test\lib\fixtures\test-data.js
test\src\fixtures\tests.js -> test\lib\fixtures\tests.js

> cost-of-modules@0.4.1 ava D:\Projects\cost-of-modules
> ava test/lib -s --no-cache

 - [?25l[?25l 
 \  
[?25l | [?25l 
 /  
[?25l - [?25l 
 \ 

 \ package.json not found!

 \ [?25l 
 | [?25l 
 / 

 / package.json not found!

 / 

 / [?25l[?25h
   2 exceptions

   × Test results were not received from test\lib\0prod.js

   × Test results were not received from test\lib\1dev.js

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "ava"
npm ERR! node v4.1.2
npm ERR! npm  v3.8.7
npm ERR! code ELIFECYCLE
npm ERR! cost-of-modules@0.4.1 ava: `ava test/lib -s --no-cache`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the cost-of-modules@0.4.1 ava script 'ava test/lib -s --no-cache'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the cost-of-modules package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ava test/lib -s --no-cache
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs cost-of-modules
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls cost-of-modules
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\Projects\cost-of-modules\npm-debug.log
npm ERR! Test failed.  See above for more details.

Process finished with exit code 1

Output from clink terminal

D:\Projects\cost-of-modules>npm test

> cost-of-modules@0.4.1 test D:\Projects\cost-of-modules
> npm run build && npm run ava

> cost-of-modules@0.4.1 build D:\Projects\cost-of-modules
> babel src -d lib && babel test/src -d test/lib

src\helpers.js -> lib\helpers.js
src\index.js -> lib\index.js
test\src\0prod.js -> test\lib\0prod.js
test\src\1dev.js -> test\lib\1dev.js
test\src\fixtures\dev-test-data.js -> test\lib\fixtures\dev-test-data.js
test\src\fixtures\helpers.js -> test\lib\fixtures\helpers.js
test\src\fixtures\test-data.js -> test\lib\fixtures\test-data.js
test\src\fixtures\tests.js -> test\lib\fixtures\tests.js

> cost-of-modules@0.4.1 ava D:\Projects\cost-of-modules
> ava test/lib -s --no-cache

package.json not found!

package.json not found!

   2 exceptions

   × Test results were not received from test\lib\0prod.js

   × Test results were not received from test\lib\1dev.js

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "ava"
npm ERR! node v4.1.2
npm ERR! npm  v3.8.7
npm ERR! code ELIFECYCLE
npm ERR! cost-of-modules@0.4.1 ava: `ava test/lib -s --no-cache`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cost-of-modules@0.4.1 ava script 'ava test/lib -s --no-cache'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the cost-of-modules package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ava test/lib -s --no-cache
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs cost-of-modules
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls cost-of-modules
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\Projects\cost-of-modules\npm-debug.log
npm ERR! Test failed.  See above for more details.

I hope that will help!

siddharthkp commented 8 years ago

@rayno Interesting, it could not even find package.json!

Are you open to a screen sharing debug session?

rayno commented 8 years ago

Yes, weekdays from 11-17 EET time.

siddharthkp commented 8 years ago

@rayno, Finally tried this on a windows machine, turns out du is not supported at all in the command prompt

When you gave me debug.txt, did you run it on a specific terminal?

rayno commented 8 years ago

Yes, you are right. I used git bash for that.

siddharthkp commented 8 years ago

@rayno, Can you run this command for me in your directory -

du --max-depth 1 -k --exclude ".*" node_modules/
rayno commented 8 years ago

Already did that, see the attachment debug.txt. The command was ran in git bash since it does not exist in windows environment. P.S.: It works in git bash, a bit slow though.

siddharthkp commented 8 years ago

@rayno, sorry about that. I completely forgot.

I still don't have an idea, why does it fail 😞

I'll get my hands on a windows machine and try again this week. Thanks for being patient.

pixelis0x commented 7 years ago

same issue win8.1

tomapp commented 7 years ago

On Windows you do :

du --max-depth 1 -k --exclude ".*" node_modules

On unix you do :

du -d 1 -k -I ".*" node_modules

According to this post it seems that windows doesn't measure the disk usage the same way as Linux does.

I think we should adjust one of this command to get the same result as the other, but i only have a windows for the moment...

siddharthkp commented 7 years ago

@tomapp Thanks! This is helpful.

A pull request will be great! If you make it work for windows, the travis build will take care of linux 😄

tomapp commented 7 years ago

Actually don't have solutions for solve this... After many tries i don't get the same value wrote in tests.

siddharthkp commented 7 years ago

@tomapp, No worries. Thanks for trying. I'll try once again when I get my hands on a windows machine.

tomapp commented 7 years ago

@siddharthkp What do you think about using getFolderSize package for replace result of command ?

siddharthkp commented 7 years ago

I started with that, then dropped. Should give it another try.

tomapp commented 7 years ago

I'll try too :)

siddharthkp commented 7 years ago

@tomapp Thanks! ❤️

aecz commented 7 years ago

Same issue here on Windows 7 64bit.

'du' is not recognized as an internal or external command,
operable program or batch file.

In the meantime, id suggest adding in the Readme, Windows support in progress

giscafer commented 7 years ago

Same issue on Windows 10 64bit

alshakero commented 7 years ago

Any reason not to use native fs instead of du? I implemented it and works perfect. Should I send a PR?

siddharthkp commented 7 years ago

@alshakero yes please

alshakero commented 7 years ago

@siddharthkp done

alshakero commented 7 years ago

@siddharthkp BTW, tests may not pass because du measures size on disk, this method measures the actual file size. You'll need to modify the fixtures.

alshakero commented 7 years ago

All tests passed now. Pushed

siddharthkp commented 7 years ago

Released in 0.4.2 🎉

Thanks @alshakero!

@rayno @tomapp @giscafer @aecz Can you update and verify?

rayno commented 7 years ago

Seems to work :)

aecz commented 7 years ago

v0.4.2 work in Windows 7 64bit, Node 6.5.0 but does not output size on disk like du on Unix. (Look at core-js size). So this change should be a breaking change (v0.5 ?) as Unix user will see their sizes changed.

npm i -g cost-of-modules@0.4.0
cost-of-modules --no-install --less
npm i -g cost-of-modules@0.4.2
cost-of-modules --no-install --less

v0.4.0 with Cygwin:

┌───────────────────────────┬─────────────┬────────┐
│ name                      │ children    │ size   │
├───────────────────────────┼─────────────┼────────┤
│ pty.js                    │ 2           │ 13.74M │
├───────────────────────────┼─────────────┼────────┤
│ @angular/compiler         │ 23          │ 6.32M  │
├───────────────────────────┼─────────────┼────────┤
│ rxjs                      │ 65          │ 5.60M  │
├───────────────────────────┼─────────────┼────────┤
│ ng2-bootstrap             │ 1           │ 4.25M  │
├───────────────────────────┼─────────────┼────────┤
│ core-js                   │ 0           │ 3.70M  │
├───────────────────────────┼─────────────┼────────┤
│ @angular/core             │ 24          │ 3.51M  │
├───────────────────────────┼─────────────┼────────┤
│ bootstrap                 │ 0           │ 2.44M  │
├───────────────────────────┼─────────────┼────────┤
│ @angular/forms            │ 0           │ 1.45M  │
├───────────────────────────┼─────────────┼────────┤
│ @angular/router           │ 0           │ 1.33M  │
├───────────────────────────┼─────────────┼────────┤
│ @angular/platform-browser │ 0           │ 1.26M  │
├───────────────────────────┼─────────────┼────────┤
│ + 15 modules              │             │        │
├───────────────────────────┼─────────────┼────────┤
│ 25 modules                │ 61 children │ 48.44M │
└───────────────────────────┴─────────────┴────────┘

v0.4.2:

┌───────────────────────────┬─────────────┬────────┐
│ name                      │ children    │ size   │
├───────────────────────────┼─────────────┼────────┤
│ pty.js                    │ 2           │ 13.20M │
├───────────────────────────┼─────────────┼────────┤
│ @angular/compiler         │ 23          │ 5.25M  │
├───────────────────────────┼─────────────┼────────┤
│ rxjs                      │ 65          │ 3.18M  │
├───────────────────────────┼─────────────┼────────┤
│ ng2-bootstrap             │ 1           │ 3.08M  │
├───────────────────────────┼─────────────┼────────┤
│ @angular/core             │ 24          │ 2.49M  │
├───────────────────────────┼─────────────┼────────┤
│ bootstrap                 │ 0           │ 2.17M  │
├───────────────────────────┼─────────────┼────────┤
│ core-js                   │ 0           │ 1.86M  │
├───────────────────────────┼─────────────┼────────┤
│ @angular/forms            │ 0           │ 1.08M  │
├───────────────────────────┼─────────────┼────────┤
│ @angular/router           │ 0           │ 1.05M  │
├───────────────────────────┼─────────────┼────────┤
│ @angular/platform-browser │ 0           │ 0.85M  │
├───────────────────────────┼─────────────┼────────┤
│ + 15 modules              │             │        │
├───────────────────────────┼─────────────┼────────┤
│ 25 modules                │ 61 children │ 37.23M │
└───────────────────────────┴─────────────┴────────┘
siddharthkp commented 7 years ago

@aecz Yes, you're right. Published 0.5.0 Unfortunately, can't take 0.4.2 back

siddharthkp commented 7 years ago

@rayno Thanks for reporting this @alshakero Thanks for fixing it!