siddharthkp / cost-of-modules

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

Always getting NaNM size when runninng the script #17

Closed kevgathuku closed 7 years ago

kevgathuku commented 7 years ago

Hi, I have been trying out this module and every time I run it, I am getting the following output. Any idea what might be wrong? Node: v6.9.1 npm: 3.10.8 yarn: 0.16.1

│ name                                    │ children     │ size  │
├─────────────────────────────────────────┼──────────────┼───────┤
│ babel-cli                               │ 181          │ NaNM  │
├─────────────────────────────────────────┼──────────────┼───────┤
│ underscore                              │ 0            │ NaNM  │
├─────────────────────────────────────────┼──────────────┼───────┤
│ babel-loader                            │ 13           │ NaNM  │
├─────────────────────────────────────────┼──────────────┼───────┤
│ babel-plugin-syntax-flow                │ 0            │ NaNM  │
├─────────────────────────────────────────┼──────────────┼───────┤
│ babel-plugin-transform-builtin-extend   │ 0            │ NaNM  │
├─────────────────────────────────────────┼──────────────┼───────┤
│ babel-plugin-transform-flow-strip-types │ 0            │ NaNM  │
├─────────────────────────────────────────┼──────────────┼───────┤
│ babel-preset-es2015                     │ 38           │ NaNM  │
├─────────────────────────────────────────┼──────────────┼───────┤
│ babel-preset-react                      │ 6            │ NaNM  │
├─────────────────────────────────────────┼──────────────┼───────┤
│ babel-preset-stage-0                    │ 30           │ NaNM  │
├─────────────────────────────────────────┼──────────────┼───────┤
│ babel-register                          │ 5            │ NaNM  │
├─────────────────────────────────────────┼──────────────┼───────┤
siddharthkp commented 7 years ago

@kevgathuku That's weird. Which OS are you on?

kevgathuku commented 7 years ago

@siddharthkp I'm on Mac OS Sierra (10.12.1)

siddharthkp commented 7 years ago

Can you run this command in the root of your repository for me

du -d 1 -k -I .cache node_modules

kevgathuku commented 7 years ago

Running that gives me this error

du: invalid option -- 'I'
Try 'du --help' for more information.
kevgathuku commented 7 years ago

If I run du -d 1 -k node_modules this is the output:

16      node_modules/.bin
172     node_modules/async
27152   node_modules/bower
16      node_modules/buffer-shims
40      node_modules/classnames
24      node_modules/combined-stream
20      node_modules/component-emitter
32      node_modules/cookiejar
4292    node_modules/core-js
36      node_modules/core-util-is
56      node_modules/debug
24      node_modules/delayed-stream
32      node_modules/encoding
44      node_modules/extend
44      node_modules/fbemitter
948     node_modules/fbjs
348     node_modules/flux
56      node_modules/form-data
84      node_modules/formidable
204     node_modules/history
68      node_modules/hoist-non-react-statics
392     node_modules/iconv-lite
456     node_modules/immutable
20      node_modules/inherits
24      node_modules/invariant
16      node_modules/is-stream
32      node_modules/isarray
48      node_modules/isomorphic-fetch
24      node_modules/js-tokens
12      node_modules/keymirror
36      node_modules/loose-envify
20      node_modules/methods
60      node_modules/mime
172     node_modules/mime-db
20      node_modules/mime-types
2888    node_modules/moment
24      node_modules/ms
128     node_modules/node-fetch
16      node_modules/object-assign
24      node_modules/process-nextick-args
192     node_modules/promise
148     node_modules/qs
16      node_modules/query-string
3112    node_modules/react
20      node_modules/react-addons-update
40      node_modules/react-dom
76      node_modules/react-input-autosize
704     node_modules/react-router
1856    node_modules/react-select
176     node_modules/readable-stream
16      node_modules/strict-uri-encode
24      node_modules/string_decoder
312     node_modules/superagent
208     node_modules/ua-parser-js
24      node_modules/util-deprecate
28      node_modules/warning
28      node_modules/whatwg-fetch
45104   node_modules
siddharthkp commented 7 years ago

@kevgathuku Ah, perfect, seems like they have changed some cli params for du

Lastly, can you give me the output of man du

kevgathuku commented 7 years ago
DU(1)                     BSD General Commands Manual                    DU(1)

NAME
     du -- display disk usage statistics

SYNOPSIS
     du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m | -g] [-x] [-I mask] [file ...]

DESCRIPTION
     The du utility displays the file system block usage for each file argument and for each directory in the file hierarchy rooted in each directory argument.
     If no file is specified, the block usage of the hierarchy rooted in the current directory is displayed.

     The options are as follows:

     -a      Display an entry for each file in a file hierarchy.

     -c      Display a grand total.

     -d depth
             Display an entry for all files and directories depth directories deep.

     -H      Symbolic links on the command line are followed, symbolic links in file hierarchies are not followed.

     -h      "Human-readable" output.  Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte.

     -I mask
             Ignore files and directories matching the specified mask.

     -g      Display block counts in 1073741824-byte (1-Gbyte) blocks.

     -k      Display block counts in 1024-byte (1-Kbyte) blocks.

     -L      Symbolic links on the command line and in file hierarchies are followed.

     -m      Display block counts in 1048576-byte (1-Mbyte) blocks.

     -P      No symbolic links are followed.  This is the default.

     -r      Generate messages about directories that cannot be read, files that cannot be opened, and so on.  This is the default case.  This option exists
             solely for conformance with X/Open Portability Guide Issue 4 (``XPG4'').

     -s      Display an entry for each specified file.  (Equivalent to -d 0)

     -x      File system mount points are not traversed.

     The du utility counts the storage used by symbolic links and not the files they reference unless the -H or -L option is specified.  If either the -H or -L
     options are specified, storage used by any symbolic links which are followed is not counted or displayed.  If more than one of the -H, -L, and -P options is
     specified, the last one given is used.

     Files having multiple hard links are counted (and displayed) a single time per du execution.  Directories having multiple hard links (typically Time Machine
     backups) are counted a single time per du execution.

ENVIRONMENT
     BLOCKSIZE  If the environment variable BLOCKSIZE is set, and the -k option is not specified, the block counts will be displayed in units of that size block.
                If BLOCKSIZE is not set, and the -k option is not specified, the block counts will be displayed in 512-byte blocks.

LEGACY DESCRIPTION
     In legacy mode, only one of the -H, -L, or -P options may be specified.

     The command will detect and report a SYMLOOP error (loop involving symbolic links).  In legacy mode, this is not the case.

     For more information about legacy mode, see compat(5).

SEE ALSO
     df(1), fts(3), compat(5), symlink(7), quot(8)

HISTORY
     A du command appeared in Version 1 AT&T UNIX.

BSD                              June 2, 2004                              BSD
siddharthkp commented 7 years ago

@kevgathuku This is weird, -I is supported.

I'll try to figure out an alternate implementation for this by avoiding -I completely.

Thanks for the pair debugging 😄

kevgathuku commented 7 years ago

Okay @siddharthkp Thanks for looking into it 😄 My guess it that it could be because I have installed the coreutils brew package which provides its own version of du which doesn't support -I

See the output of du --help

Usage: du [OPTION]... [FILE]...
  or:  du [OPTION]... --files0-from=F
Summarize disk usage of the set of FILEs, recursively for directories.

Mandatory arguments to long options are mandatory for short options too.
  -0, --null            end each output line with NUL, not newline
  -a, --all             write counts for all files, not just directories
      --apparent-size   print apparent sizes, rather than disk usage; although
                          the apparent size is usually smaller, it may be
                          larger due to holes in ('sparse') files, internal
                          fragmentation, indirect blocks, and the like
  -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                           '-BM' prints sizes in units of 1,048,576 bytes;
                           see SIZE format below
  -b, --bytes           equivalent to '--apparent-size --block-size=1'
  -c, --total           produce a grand total
  -D, --dereference-args  dereference only symlinks that are listed on the
                          command line
  -d, --max-depth=N     print the total for a directory (or file, with --all)
                          only if it is N or fewer levels below the command
                          line argument;  --max-depth=0 is the same as
                          --summarize
      --files0-from=F   summarize disk usage of the
                          NUL-terminated file names specified in file F;
                          if F is -, then read names from standard input
  -H                    equivalent to --dereference-args (-D)
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
      --inodes          list inode usage information instead of block usage
  -k                    like --block-size=1K
  -L, --dereference     dereference all symbolic links
  -l, --count-links     count sizes many times if hard linked
  -m                    like --block-size=1M
  -P, --no-dereference  don't follow any symbolic links (this is the default)
  -S, --separate-dirs   for directories do not include size of subdirectories
      --si              like -h, but use powers of 1000 not 1024
  -s, --summarize       display only a total for each argument
  -t, --threshold=SIZE  exclude entries smaller than SIZE if positive,
                          or entries greater than SIZE if negative
      --time            show time of the last modification of any file in the
                          directory, or any of its subdirectories
      --time=WORD       show time as WORD instead of modification time:
                          atime, access, use, ctime or status
      --time-style=STYLE  show times using STYLE, which can be:
                            full-iso, long-iso, iso, or +FORMAT;
                            FORMAT is interpreted like in 'date'
  -X, --exclude-from=FILE  exclude files that match any pattern in FILE
      --exclude=PATTERN    exclude files that match PATTERN
  -x, --one-file-system    skip directories on different file systems
      --help     display this help and exit
      --version  output version information and exit

Display values are in units of the first available SIZE from --block-size,
and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).

The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: <http://www.gnu.org/software/coreutils/du>
or available locally via: info '(coreutils) du invocation'
siddharthkp commented 7 years ago

Ah, that seems to be it, this one follows -X instead of the native -I That sounds like a very specific case, I'm not sure if the tool should support it.

Although, you can make it work for you by editing /usr/local/lib/node_modules/cost-of-modules/lib/helpers.js line 73 😉

kevgathuku commented 7 years ago

It might be more popular, but I guess we'll just have to see if more people experience the same. Is there a way to try out the first command, and if it doesn't work, to use the darwin workaround? Thanks for your time

siddharthkp commented 7 years ago

Is there a way to try out the first command, and if it doesn't work, to use the darwin workaround?

I'm not sure if it's possible.

kevgathuku commented 7 years ago

Okay. I'll comment out the darwin part in the meantime.