egoist / package-size

Get the bundle size of an npm package.
MIT License
425 stars 26 forks source link

cwd flag errors - "Cannot read property 'version' of undefined" #14

Open blueShirtBen opened 6 years ago

blueShirtBen commented 6 years ago

I'm trying to use the cwd flag to get the package size on a few packages in my working directory. It appears to be pulling from cache because it always returns the same information no matter the package name I pass to it. So when I use the no cache flag I then get the "version is undefined" error.

egoist commented 6 years ago

I think we should disable cache for cwd by default then 😅

But I don't get that version is undefined error, what is the exact command you ran?

blueShirtBen commented 6 years ago

package-size react --cwd --no-cache. Looks like the error comes from index.js at your info object. pkg => ${pkg.name}${pkg.path ? /${pkg.path} : ''}@${packageInfo[pkg.name].version} )

I got it to work locally when I did something like this. ${pkg.name}${pkg.path ?/${pkg.path}: ''}@${(packageInfo[pkg.name] || {}).version}