Next.js: 'BUNDLE_ANALYZE' is not recognized as an internal or external command

Created on 1 Mar 2019  路  4Comments  路  Source: vercel/next.js

Examples bug report

'BUNDLE_ANALYZE' is not recognized as an internal or external command

Example name

analyze-bundle-app

Describe the bug

Hi Team, I have downloaded Analyzer Bundles example using npx create-next-app --example analyze-bundles analyze-bundles-app(new project). Then installed all required plugins from project folder. When running app using npm run dev, it works fine, but for analyze, when I am executing command(npm run analyze), it is giving me error 'BUNDLE_ANALYZE' is not recognized as an internal or external command.

Please let me know what I am missing or do I need to install any more plugin to execute this command?

I have taken reference from https://github.com/zeit/next.js/tree/master/examples/analyze-bundles

Most helpful comment

I'm assuming you're on a Windows machine.

Please install cross-env and append it to each script with BUNDLE_ANALYZE.

"analyze": "cross-env BUNDLE_ANALYZE=both next build"

All 4 comments

I'm assuming you're on a Windows machine.

Please install cross-env and append it to each script with BUNDLE_ANALYZE.

"analyze": "cross-env BUNDLE_ANALYZE=both next build"

Could you send a PR for this if it works? 馃槃

the BUNDLE_ANALYZE flag doesn't seem to work. I can only make bundle analyze work with ANALYZE=true

It seems that this PR https://github.com/zeit/next.js/pull/9645 removed the support for analyzeServer and analyzeBrowser and hence BUNDLE_ANALYZE in withBundleAnalyzer wouldn't work.

It used to work like this:
https://github.com/zeit/next-plugins/tree/139d283/packages/next-bundle-analyzer

Was this page helpful?
0 / 5 - 0 ratings