create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

source-map-explorer cannot generate report even with --only-mapped param

Open mohsentaleb opened this issue 4 years ago • 2 comments

I tried to build a fresh create-react-app project, then wanted to generate reports for the built bundles with source-map-explorer. At first I got this error described in https://github.com/facebook/create-react-app/issues/8430. Passed in --only-mapped param and no luck either.

Environment

current version of create-react-app: 5.0.0
  running from /home/mohsen/.npm/_npx/2484/lib/node_modules/create-react-app

  System:
    OS: Linux 4.4 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
  Binaries:
    Node: 14.18.3 - ~/.nvm/versions/node/v14.18.3/bin/node
    Yarn: 1.22.11 - /mnt/c/Users/Mohsen/AppData/Roaming/npm/yarn
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.3/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    react: ^17.0.2 => 17.0.2
    react-dom: ^17.0.2 => 17.0.2
    react-scripts: 5.0.0 => 5.0.0
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

  1. Create the project using npx create-react-app test
  2. Try to build the project
    $ npm run build
    
    > [email protected] build /mnt/c/wwwroot/test
    > react-scripts build
    
    Creating an optimized production build...
    Compiled successfully.
    
    File sizes after gzip:
    
      43.7 kB  build/static/js/main.c8f1f991.js
      1.77 kB  build/static/js/787.5cebbde9.chunk.js
      541 B    build/static/css/main.073c9b0a.css
    
    The project was built assuming it is hosted at /.
    You can control this with the homepage field in your package.json.
    
    The build folder is ready to be deployed.
    You may serve it with a static server:
    
      npm install -g serve
      serve -s build
    
    Find out more about deployment here:
    
      https://cra.link/deployment
    
  3. Add this like to package.json -> scripts - Be sure to install source-map-explorer first:
    "analyze": "source-map-explorer 'build/static/js/*.js' --only-mapped" 
    
  4. Run analyze script:
    $ npm run analyze
    
    > [email protected] analyze /mnt/c/wwwroot/test
    > source-map-explorer 'build/static/js/*.js' --only-mapped
    

Expected behavior

npm run analyze should show open browser with the generated report or throw an error in the console.

Actual behavior

Browser is not opened and nothing is logged in console.

mohsentaleb avatar Jan 17 '22 06:01 mohsentaleb

I tried the above steps. It is working as expected on Mac Os. Is this Linux specific issue?

diksha0562 avatar Jun 05 '23 09:06 diksha0562

I found a possible workaround (worked in my case)

Add a --html param to the command, e.g.

source-map-explorer 'dist/app/static/js/*.js' --html result.html

Based on this, I suspect the cause to be either of:

  • permissions to the temp folder, where the source-map-explorer tries to write the html before opening a browser
  • broken "association of the default browser" in your distro, whatever that could mean (see this)

lost-valley avatar Jan 20 '25 09:01 lost-valley