Gulp:UnhandledPromiseRejectionWarning报错

使用构建工具Gulp来 执行图片压缩打包过程中出现报错

(node:20312) UnhandledPromiseRejectionWarning: Error: spawn E:\项目\支付\node_modules\optipng-bin\vendor\optipng.exe ENOENT
    at notFoundError (E:\项目\支付\node_modules\cross-spawn\lib\enoent.js:11:11)
    at verifyENOENT (E:\项目\支付\node_modules\cross-spawn\lib\enoent.js:46:16)
    at ChildProcess.cp.emit (E:\项目\支付\node_modules\cross-spawn\lib\enoent.js:33:19)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
(node:20312) 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: 2)
(node:20312) [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.
(node:20312) UnhandledPromiseRejectionWarning: Error: spawn E:\项目\支付\node_modules\optipng-bin\vendor\optipng.exe ENOENT
    at notFoundError (E:\项目\支付\node_modules\cross-spawn\lib\enoent.js:11:11)
    at verifyENOENT (E:\项目\支付\node_modules\cross-spawn\lib\enoent.js:46:16)
    at ChildProcess.cp.emit (E:\项目\支付\node_modules\cross-spawn\lib\enoent.js:33:19)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
(node:20312) 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: 4)
(node:20312) UnhandledPromiseRejectionWarning: Error: spawn E:\项目\支付\node_modules\optipng-bin\vendor\optipng.exe ENOENT
    at notFoundError (E:\项目\支付\node_modules\cross-spawn\lib\enoent.js:11:11)
    at verifyENOENT (E:\项目\支付\node_modules\cross-spawn\lib\enoent.js:46:16)
    at ChildProcess.cp.emit (E:\项目\支付\node_modules\cross-spawn\lib\enoent.js:33:19)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
(node:20312) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without

卸载gulp-imagemin npm uninstall gulp-imagemin

重新安装 npm i gulp-imagemin -D

还需要安装两个插件用来转化压缩图片 npm i imagemin-gifsicle imagemin-optipng -D (已经安装的报错就是因为这两个插件,卸载重新安装,最好用cnpm i imagemin-gifsicle imagemin-optipng -D 安装 );

安装完重新运行构建任务就可以了

你可能感兴趣的:(Gulp构建工具报错)