首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在npm运行生成上缩减代码

无法在npm运行生成上缩减代码
EN

Stack Overflow用户
提问于 2018-07-23 08:58:51
回答 2查看 6.1K关注 0票数 2

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

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

这是我的错误

代码语言:javascript
复制
> 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.

这是我的错误文件

代码语言:javascript
复制
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 ]

这是我的软件包配置

代码语言:javascript
复制
{
  "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"
  }
}

EN

回答 2

Stack Overflow用户

发布于 2018-10-11 15:11:19

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

票数 3
EN

Stack Overflow用户

发布于 2018-07-23 09:26:20

它似乎在你的一个依赖项的this line上爆炸了。浏览一下create-react-app代码库,我猜他们在Webpack配置中传递给UglifyJS的选项不会解析ES2015+。新的since包可能应该被Babelified来支持旧版本的Node和旧浏览器,因为人们通常不会Babelify他们的依赖项。

这个包似乎也不是浏览器友好的,它看起来是应该在服务器端使用的东西。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51470429

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档