javascript - 无法在 npm run build 上缩小代码

标签 javascript json reactjs npm create-react-app

我已经完成了创建的 react 应用程序 创建 react 应用程序 ,我在本地使用 npm start 运行时没有任何问题,但是当我尝试使用 npm-build

我在缩小代码时遇到错误。我尝试克隆我的项目并尝试构建它,我尝试创建一个测试项目并尝试 npm build 并且没有任何问题,只有当我尝试构建我的完整项目时。

这是我的错误

> test@0.1.0 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! test@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

这是我的错误文件

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 npm@6.2.0
3 info using node@v9.2.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle test@0.1.0~prebuild: test@0.1.0
6 info lifecycle test@0.1.0~build: test@0.1.0
7 verbose lifecycle test@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle test@0.1.0~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 test@0.1.0~build: CWD: C:\Users\Jonathan Stroz\Documents\HackerNews-Production-master
10 silly lifecycle test@0.1.0~build: Args: [ '/d /s /c', 'react-scripts build' ]
11 silly lifecycle test@0.1.0~build: Returned: code: 1  signal: null
12 info lifecycle test@0.1.0~build: Failed to exec build script
13 verbose stack Error: test@0.1.0 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 test@0.1.0
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 test@0.1.0 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the test@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

这是我的包配置

{
  "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"
  }
}

最佳答案

您可能使用的是旧版本的react-scripts,请尝试升级到react-scripts@>=2.0.0

关于javascript - 无法在 npm run build 上缩小代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51470429/

相关文章:

javascript - Highcharts 双 x 轴列 + 线正在向辅助 x 轴添加刻度

javascript - 使用 <a> 标记和 onclick 使用 javascript 更改页面元素的样式?

python - TypeError : jsonify() argument after ** must be a mapping, 未列出使用 Flask 返回的 JSON

java - 数据库 DataFrame Null 值未传入 Json 文件

ios - 如何在 iOS 的 UITableView 的最后一行添加一行字符串?

javascript - 如何通过单击ReactJS网页上的按钮通过USB发送一些位?

javascript - 设置后React状态为空

reactjs - Bootstrap Dropdown 在 React 中不起作用

javascript - 如何强制 jQuery 首先加载?

javascript - Ember.Select 的奇怪问题