danvk / source-map-explorer

Analyze and debug space usage through source maps
Apache License 2.0
3.82k stars 100 forks source link

Unable to open web browser. Invalid switch - "/tmp" #161

Open imoark opened 4 years ago

imoark commented 4 years ago

Description I'm working on create-react-app@3.0.1 and I got this error.

$ source-map-explorer build/static/js/*.js
build/static/js/2.9d3308cf.chunk.js
  Unable to map 86/5098426 bytes (0.00%)
build/static/js/main.b235dfa8.chunk.js
  Unable to map 77/248845 bytes (0.03%)
build/static/js/runtime~main.a8a9905a.js
  Unable to map 13/1502 bytes (0.87%)
Unable to open web browser. Invalid switch - "/tmp".
Either run with --html, --json, --tsv, --file, or view HTML for the visualization at:
/tmp/sme-result-2020113-220-1f3lsmg.3b1gf.html

Steps to reproduce

  1. Build your create-react-app with npm run build
  2. run $ source-map-explorer build/static/js/*.js
  3. See error

Expected behavior It should open the web browser and show the visualization.

Environment

Additional context I can still see the /tmp/sme-result-2020113-220-1f3lsmg.3b1gf.html generated. I can still also put --html params and it will generate the file alright. I'm just wondering how to get the proper/expected behaviour if I am using WSL.

Couldn't test with source-map-explorer@2.2.2 because it's too slow.

I tried with source-map-explorer@2.0.1

$ source-map-explorer build/static/js/*.js
build/static/js/2.9d3308cf.chunk.js
  Unable to map 130/5098425 bytes (0.00%)
build/static/js/main.b235dfa8.chunk.js
  Unable to map 124/248844 bytes (0.05%)
build/static/js/runtime~main.a8a9905a.js
  1. Your source map only contains one source (../webpack/bootstrap).
  This can happen if you use browserify+uglifyjs, for example, and don't set the --in-source-map flag to uglify.
  See https://github.com/danvk/source-map-explorer/blob/master/README.md#generating-source-maps
  2. Unable to map 62/1501 bytes (4.13%)
Unable to open web browser. Invalid switch - "/tmp".
Either run with --html, --json, --tsv, --file, or view HTML for the visualization at:
/tmp/sme-result-2020113-146-119t6vf.v2pk.html
nikolay-borzov commented 4 years ago

sme uses open for opening files.

imoark commented 4 years ago

I see. I guess open doesn't support WSL 1 very well.

Then, my workaround for now:

  1. $ source-map-explorer build/static/js/*.js --html ./some-file-name.html and manually open the some-file-name.html
  2. Or use MINGW64 terminal on Windows

If anyone can have a better solution, kindly leave a comment below.

stof commented 3 years ago

According to their readme, it supports WSL paths under /mnt/* (i.e. files being on the windows filesystem). But here, the file is on the linux filesystem, and so is affected by https://github.com/sindresorhus/open/issues/174