Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when i want to find out size of package 'zx', it throw a build error: 'Cannot use keyword 'await' outside an async function' #39

Open
cy-98 opened this issue Jul 8, 2021 · 1 comment

Comments

@cy-98
Copy link

cy-98 commented Jul 8, 2021

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?

@parties
Copy link

parties commented Sep 4, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants