package-build-stats
package-build-stats copied to clipboard
when i want to find out size of package 'zx', it throw a build error: 'Cannot use keyword 'await' outside an async function'
when i want to find out size of package 'zx', it throw a build error: 'Cannot use keyword 'await' outside an async function'
it seems, zx used new feature of node. Is package-build-stats only support to build web package?
How can i get size of node package which used node feature without webpack loader?
Without seeing a code example, my best guess is that you're doing something like this:
const { getPackageStats } = require('package-build-stats')
const result = await getPackageStats('some-package');
console.log(result);
Generally, you can't call await
outside of an async function, meaning: you need to wrap whatever is calling await
in an async function, like this:
// index.js
const { getPackageStats } = require('package-build-stats')
async function getStats() {
const results = await getPackageStats('faker')
console.log(results);
}
getStats();
Does this get you any further? Or were you trying something else? Give us an example so we can point you in the right direction.