create-react-app source-map-explorer 无法生成报告,即使使用了 --only-mapped 参数,

disbfnqx  于 2个月前  发布在  React
关注(0)|答案(1)|浏览(103)

我尝试构建一个新的 create-react-app 项目,然后想用 source-map-explorer 为构建的包生成报告。起初我遇到了 #8430 中描述的错误。传入了 --only-mapped 参数,但也没有成功。

环境

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

重现步骤

  1. 使用 npx create-react-app test 创建项目
  2. 尝试构建项目
$ npm run build

> test@0.1.0 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
  1. 将以下内容添加到 package.json -> scripts 中:确保首先安装 source-map-explorer:
"analyze": "source-map-explorer 'build/static/js/*.js' --only-mapped"
  1. 运行分析脚本:
$ npm run analyze

> test@0.1.0 analyze /mnt/c/wwwroot/test
> source-map-explorer 'build/static/js/*.js' --only-mapped

预期行为

npm run analyze 应该在浏览器中打开生成的报告,或者在控制台中抛出错误。

实际行为

浏览器没有打开,控制台也没有记录任何内容。

9nvpjoqh

9nvpjoqh1#

我尝试了上述步骤,在Mac OS上运行正常。这是Linux特定的问题吗?

相关问题