0

当我运行时,npx webpack-cli --analyze --node-env development我收到一个关于它不喜欢的错误<React.StrictMode>

Webpack Bundle Analyzer is started at http://127.0.0.1:8888
Use Ctrl+C to close it
Hash: 24852f2f5b5cef02cfe2
Version: webpack 4.42.0
Time: 57ms
Built at: 08/11/2021 2:53:12 PM
  Asset      Size  Chunks             Chunk Names
main.js  4.09 KiB    main  [emitted]  main
Entrypoint main = main.js
[./src/index.js] 316 bytes {main} [built] [failed] [1 error]

ERROR in ./src/index.js 9:2
Module parse failed: Unexpected token (9:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| ReactDOM.render(
>   <React.StrictMode>
|     <App />
|   </React.StrictMode>,

我正在使用来自.\node_modules\react-scripts\config\webpack.config.js. 为什么 webpack 不喜欢 React.StrictMode?

4

1 回答 1

0

我找到了答案,只需使用source-map-explorer

"scripts": {
    "start": "rimraf ./build && react-scripts start",
    "build": "react-scripts build",
    "analyze": "source-map-explorer 'build/static/js/*.js'",
    "test": "cross-env CI=true react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "lint": "eslint ./src/"
  },
于 2021-08-14T20:45:19.340 回答