Jonathan Stro
Jonathan Stro

Reputation: 109

Failed to minify code on npm run build

I have finished my react application that was created with create-react-app , i have no issues running on local with npm start but when i try to build using npm-build

i get an error on minifying the code. I have tried cloning my project and trying to build it, i have tried creating a test project and trying npm build and am having no problems with it, it is only when i try to build my full project.

this is my error

> [email protected] build C:\Users\Jonathan Stroz\Documents\HackerNews-Production-master
> react-scripts build

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file:

        ./node_modules/newsapi/index.js:20

Read more here: 

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

this my error file

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\Jonathan Stroz\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 info lifecycle [email protected]~build: [email protected]
7 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build: PATH: C:\Users\Jonathan Stroz\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Jonathan Stroz\Documents\HackerNews-Production-master\node_modules\.bin;C:\Users\Jonathan Stroz\gcc\bin;C:\Users\Jonathan Stroz\gcc\libexec\gcc\i686-pc-mingw32\4.9.2;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Python33;C:\Python33\Scripts;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\dotnet\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Yarn\bin\;C:\Users\Jonathan Stroz\gcc\bin;C:\Users\Jonathan Stroz\gcc\libexec\gcc\i686-pc-mingw32\4.9.2;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\MATLAB\R2016b\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;PATH%;C:\Python34\Scripts;C:\Program Files\Java\jdk1.8.0_144\bin;C:\Users\Jonathan Stroz\AppData\Local\GitHubDesktop\bin;C:\Users\Jonathan Stroz\AppData\Local\atom\bin;C:\Users\ugur\AppData\Roaming\npm;C:\Users\Jonathan Stroz\AppData\Roaming\npm;;C:\Users\Jonathan Stroz\AppData\Local\Microsoft\WindowsApps;C:\Users\Jonathan Stroz\AppData\Local\Yarn\bin
9 verbose lifecycle [email protected]~build: CWD: C:\Users\Jonathan Stroz\Documents\HackerNews-Production-master
10 silly lifecycle [email protected]~build: Args: [ '/d /s /c', 'react-scripts build' ]
11 silly lifecycle [email protected]~build: Returned: code: 1  signal: null
12 info lifecycle [email protected]~build: Failed to exec build script
13 verbose stack Error: [email protected] build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\Jonathan Stroz\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:304:16)
13 verbose stack     at EventEmitter.emit (events.js:159:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\Jonathan Stroz\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:159:13)
13 verbose stack     at maybeClose (internal/child_process.js:943:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\Users\Jonathan Stroz\Documents\HackerNews-Production-master\src
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Jonathan Stroz\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v9.2.0
19 verbose npm  v6.2.0
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] build: `react-scripts build`
22 error Exit status 1
23 error Failed at the [email protected] build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

this is my package config

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "bluebird": "^3.5.1",
    "bootstrap": "^4.1.2",
    "minify": "^3.0.5",
    "netlify": "^1.2.0",
    "newsapi": "^2.2.2",
    "node-fetch": "^2.2.0",
    "react": "^16.4.1",
    "react-dom": "^16.4.1",
    "react-icons-kit": "^1.1.6",
    "react-popup": "^0.9.3",
    "react-scripts": "1.1.4",
    "react-select": "^1.2.1",
    "react-tabs-redux": "^3.0.2",
    "reactjs-popup": "^1.1.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

Upvotes: 4

Views: 8841

Answers (2)

Bruce Wang
Bruce Wang

Reputation: 47

you're likely using an old version of react-scripts,try upgrading to react-scripts@>=2.0.0

Upvotes: 5

Zac Anger
Zac Anger

Reputation: 7747

It seems to be blowing up on this line of one of your dependencies. Looking through the create-react-app repo, I would guess that the options they're passing to UglifyJS in their Webpack config don't parse ES2015+. That newsapi package should probably be Babelified to support older versions of Node and older browsers, since usually folks don't Babelify their dependencies.

That package also doesn't seem to be browser-friendly, it looks like it's something that should be used server-side.

Upvotes: 3

Related Questions