react项目部署npm run build 报错

React版本16.2.0,已经eject了,npm run build报错

$ npm run build

> wolf@0.1.0 build 
> node scripts/build.js

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

Failed to minify the code from this file:

     ./node_modules/query-string/index.js:8

Read more here: http://bit.ly/2tRViJ9

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wolf@0.1.0 build: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wolf@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
阅读 10.1k
3 个回答

官方已经给出解释了,点进去链接:

发现是官方说的可能用了第三方软件包没有被正确编译成ES5,你去检查一下自己的代码用到这些软件包的地方,如图所示,用这些方法试试

图片描述

node.js用的什么版本,降为7.x看看。

新手上路,请多包涵

一. 问题原因

今天写项目同遇到这个问题。根据英文

Failed to minify the code from this file:
   ./node_modules/query-string/index.js:8

很明显可以发现是query-string这个库未能正确编译

二. 解决方法

降级Query-String库

原先是query-string@6.2.0,降到query-string@5.1.1,成功build
项目文件夹内,命令行中:

npm install query-string@5.1.1

Appendix

参考修改链接: https://github.com/marmelab/r...

有问题欢迎私信

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题