webpack报错:DeprecationWarning:Unhandled promise rejections are deprecated

在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的版本,我更新后的版本如下:
在这里插入图片描述
步骤:

npm install

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

npm run build

这里需要在package.json配置这个才能这样运行
在这里插入图片描述
然后成功了:
在这里插入图片描述

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值