Unable to minify react application to production

905 Views Asked by At

I'm having issued generate a production build of the react application and have this error.

    Failed to minify the code from this file: 

        ./node_modules/d3-array/src/count.js:2

Read more here: ...

npm ERR! code 1
npm ERR! path C:\Repository\Notes\Trunk\New\WebApp
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\simon.lam\AppData\Local\npm-cache\_logs\2021-09-29T20_18_32_241Z-debug.log
npm ERR! code 1
npm ERR! path C:\Repository\Notes\Trunk\New\WebApp
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c npm-run-all build-css build-js

I looked into this page: https://create-react-app.dev/docs/troubleshooting/#npm-run-build-fails-to-minify

I think I need to upgrade the react-script. I looked into package.json and found no react-script

This is my package.json file:

"scripts": {
    "build-css": "node-sass-chokidar --include-path ./node_modules ./sass -o src/css/",
    "watch-css": "npm run build-css && node-sass-chokidar --include-path ./node_modules ./sass -o src/css/ --watch --recursive",
    "start-js": "node scripts/start.js",
    "start": "npm-run-all -p watch-css start-js",
    "build-js": "node scripts/build.js",
    "build": "npm-run-all build-css build-js",
    "test": "node scripts/test.js --env=jsdom",
    "react-devtools": "react-devtools"
  },
  "devDependencies": {
    "react-devtools": "^3.2.3",
    "webpack-bundle-analyzer": "^2.13.1"
  },
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx,mjs}"
    ],
    "setupFiles": [
      "<rootDir>/config/polyfills.js"
    ],
    "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
      "<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
    ],
    "testEnvironment": "node",
    "testURL": "http://localhost",
    "transform": {
      "^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
    ],
    "moduleNameMapper": {
      "^react-native$": "react-native-web"
    },
    "moduleFileExtensions": [
      "web.js",
      "js",
      "json",
      "web.jsx",
      "jsx",
      "node",
      "mjs"
    ]
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  },
  "eslintConfig": {
    "extends": "react-app"
  }
}

What i know it also use react-script but it was extracted out of the react-script for some reason.

Do anyone know a way to handle this minified issued for production build?

    verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'run',
0 verbose cli   'build-js'
0 verbose cli ]
1 info using [email protected]
2 info using [email protected]
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 3ms
5 timing config:load:builtin Completed in 4ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 1ms
8 timing config:load:file:C:\Repository\WebApp\Trunk\WebApp-New\WebApp\.npmrc Completed in 1ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:C:\Users\simon.lam\.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:C:\Users\simon.lam\AppData\Roaming\npm\etc\npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 10ms
19 verbose npm-session 34c1e0f792979f56
20 timing npm:load Completed in 19ms
21 timing command:run Completed in 89011ms
22 verbose stack Error: command failed
22 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
22 verbose stack     at ChildProcess.emit (node:events:369:20)
22 verbose stack     at maybeClose (node:internal/child_process:1067:16)
22 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
23 verbose pkgid [email protected]
24 verbose cwd C:\Repository\WebApp\Trunk\WebApp-New\WebApp
25 verbose Windows_NT 10.0.19043
26 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build-js"
27 verbose node v15.12.0
28 verbose npm  v7.6.3
29 error code 1
30 error path C:\Repository\WebApp\Trunk\WebApp-New\WebApp
31 error command failed
32 error command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js
33 verbose exit 1
0

There are 0 best solutions below