danvk / source-map-explorer

Analyze and debug space usage through source maps
Apache License 2.0
3.81k stars 119 forks source link

Can't require package (v5.0.1) #216

Open ghost opened 2 years ago

ghost commented 2 years ago

I'm trying to analyze a react app build files source-map-explorer 'build/static/js/*.js' , but I'm getting this error:

> my-project@0.0.1 analyze
> source-map-explorer 'build/static/js/*.js'

\my-project\node_modules\wrap-ansi\node_modules\string-width\index.js:3
const isFullwidthCodePoint = require('is-fullwidth-code-point');
                             ^

Error [ERR_REQUIRE_ESM]: require() of ES Module \my-project\node_modules\is-fullwidth-code-point\index.js from \my-project\node_modules\wrap-ansi\node_modules\string-width\index.js not supported.
Instead change the require of \my-project\node_modules\is-fullwidth-code-point\index.js in \my-project\node_modules\wrap-ansi\node_modules\string-width\index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (\my-project\node_modules\wrap-ansi\node_modules\string-width\index.js:3:30)
    at Object.<anonymous> (\my-project\node_modules\wrap-ansi\index.js:2:21)
    at Object.<anonymous> (\my-project\node_modules\source-map-explorer\node_modules\cliui\build\index.cjs:293:14)
    at Object.<anonymous> (\my-project\node_modules\source-map-explorer\node_modules\yargs\build\index.cjs:2861:12)
    at Object.<anonymous> (\my-project\node_modules\source-map-explorer\node_modules\yargs\index.cjs:5:30)
    at Object.<anonymous> (\my-project\node_modules\source-map-explorer\bin\cli.js:10:33) {
  code: 'ERR_REQUIRE_ESM'
}