解决npm 编译时报node_modules/optipng-bin/vendor/optipng ENOENT

现象

执行npm run build 时报node_modules/optipng-bin/vendor/optipng ENOENT这个错误
日志如下

15:02:26  events.js:183
15:02:26        throw er; // Unhandled 'error' event
15:02:26        ^
15:02:26  Error: spawn node_modules/[email protected]@optipng-bin/vendor/optipng ENOENT
15:02:26      at _errnoException (util.js:1024:11)
15:02:26      at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
15:02:26      at onErrorNT (internal/child_process.js:372:16)
15:02:26      at _combinedTickCallback (internal/process/next_tick.js:138:11)
15:02:26      at process._tickCallback (internal/process/next_tick.js:180:9)
15:02:26  npm ERR! code ELIFECYCLE
15:02:26  npm ERR! errno 1
15:02:26  npm ERR! [email protected] build: `export NODE_ENV=production && webpack --display-error-details --config webpack.config.js && gulp check-code && gulp build`
15:02:26  npm ERR! Exit status 1
15:02:26  npm ERR! 
15:02:26  npm ERR! Failed at the [email protected] build script.
15:02:26  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
15:02:26  
15:02:26  npm ERR! A complete log of this run can be found in:

解决办法

https://github.com/panteng/wechat-h5-boilerplate/issues/5
执行下面的命令卸载重装 gulp-imagemin依赖即可,需要注意版本区别

npm install node-gyp
npm uninstall gulp-imagemin
npm install gulp-imagemin

我的版本是4.1.0 就执行npm install [email protected]安装, npm rebuild命令说不定也有帮助,根据自己情况决定是否删除node_modules

你可能感兴趣的:(Vue,npm,node.js,javascript,vue,前端)