首页 > 解决方案 > 在 npm run start 后构建卡在 91%

问题描述

当我执行 npm run start 时,突然出现了这个错误。该项目是用 ant-design pro 构建的。可悲的是,它没有告诉我错误在哪里。你能帮我找出错误或修复它吗?构建只是卡在 91%,然后我收到错误消息。

这是错误:

 build [==================  ] 91%(node:6978) UnhandledPromiseRejectionWarning: RangeError: Invalid string length
    at formatError (/home/teks/trips/may26th/smarttrips_react/node_modules/webpack/lib/Stats.js:223:30)
    at Array.map (<anonymous>)
    at Stats.toJson (/home/teks/trips/may26th/smarttrips_react/node_modules/webpack/lib/Stats.js:230:31)
    at Compiler.<anonymous> (/home/teks/trips/may26th/smarttrips_react/node_modules/html-webpack-plugin/index.js:68:44)
    at Compiler.applyPluginsAsyncSeries (/home/teks/trips/may26th/smarttrips_react/node_modules/tapable/lib/Tapable.js:206:13)
    at Compiler.emitAssets (/home/teks/trips/may26th/smarttrips_react/node_modules/webpack/lib/Compiler.js:354:8)
    at onCompiled (/home/teks/trips/may26th/smarttrips_react/node_modules/webpack/lib/Compiler.js:58:19)
    at applyPluginsAsync.err (/home/teks/trips/may26th/smarttrips_react/node_modules/webpack/lib/Compiler.js:510:14)
    at next (/home/teks/trips/may26th/smarttrips_react/node_modules/tapable/lib/Tapable.js:202:11)
    at Compiler.<anonymous> (/home/teks/trips/may26th/smarttrips_react/node_modules/webpack/lib/CachePlugin.js:78:5)
    at next (/home/teks/trips/may26th/smarttrips_react/node_modules/tapable/lib/Tapable.js:204:14)
    at /home/teks/trips/may26th/smarttrips_react/node_modules/hard-source-webpack-plugin/index.js:2075:7
    at <anonymous>
(node:6978) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6978) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

编辑:我还将我的 npm 更新到版本 6,但仍然收到相同的错误消息。请指教。

标签: node.jsreactjsantd

解决方案


可能是因为本地主机没有在系统的“主机”文件中使用所需的语法定义。该文件可以位于@:

linux

etc/hosts

视窗

c:\ **Windows** \System32\Drivers\ **etc** \ **hosts**

即文件有一些错误的输入。

因此,尝试用下面的文本替换该文件中的所有内容,因为这是正常工作时主机文件中始终存在的默认文本:

127.0.0.1   localhost

255.255.255.255 broadcasthost

::1             localhost

fe80::1%lo0 localhost

推荐阅读