webpack报错:DeprecationWarning:Unhandled promise rejections are deprecated

我要冲啦个人网站建设2020-10-29web前端

在webpack打包时出错:DeprecationWarning

(node:3408) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error by rejecting a promise which was not handled with .catch(). To terminate the node
process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3408) [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.

这主要就是版本原因,你的webpack的版本和loader的版本不匹配,我这里的webpack版本是3.6.0,如果你直接安装css-loader、less-loader、style-loader…都是默认安装的最新版本的loader,这很可能与你当前版本的webpack不匹配,因此我们需要降低loader的版本,我更新后的版本如下:

在这里插入图片描述

步骤:

1、npm install

这个步骤是按照package.json安装相应的依赖

2、npm run build

这里需要在package.json配置这个才能这样运行

在这里插入图片描述

然后成功了:

在这里插入图片描述

如果你出现的问题跟我的一样,那大概率也是版本原因,进行loader版本的降低就可以了。

文章关键词
webpack报错
DeprecationWarning