I’ve encountered the following error - below. I have tried reinstalling node (clearing cache after uninstall), a fresh install of Sage 8.2.1, and a few other suggestions I had found. I’m running Node V 0.12.3, Bower V 1.4.1, Gulp V 3.8.11, PHP 5.5.2.
This error is thrown after executing “gulp” command when attempting to optimize images (Starting ‘images’). If no images to optimize in assets/images, no error. Everything worked brilliantly at first, then this just started happening; nothing changed on my end that I’m aware of.
Any suggestions greatly appreciated!
events.js:85
throw er; // Unhandled ‘error’ event
^
Error: spawn /Users/inHouse/Documents/www/vagrant/www/devtheme/htdocs/wp-content/themes/devtheme/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin/vendor/optipng ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
since I think the optipng binaries failed to build during the initial npm install process and something wasn’t clearing right in the system. npm rebuild was the thing that did the trick.
Ran into this issue on a build of Sage from July 2015. Jpegtran wasn’t minimizing images in the theme’s assets directly. Here’s what I did to resolve it without reinstalling the entire node_modules direcotry.
I removed all of the images from assets
ran gulp to confirm that was causing the error
uninstalled gulp-imagemin
checked the package.json to verify the modules version
installed the build specific version of gulp-imagemin
Thanks for posting this. Just curious why you wouldn’t want to reinstall the node_modules directory. I know it can take a few minutes to run npm install, but the method you describe seems a lot more manual time consuming
Overall, this process took me about one minute to complete. I just wrote a detailed set of instructions to contribute to the community. Deleting and installing all node modules takes much longer, but has the benefit of requiring less effort for the developer. I was short on time, and freshly caffeinated, so this was the best approach for me personally.
The decision was driven by where I was in the development process and the non-technical project requirements I was managing. I didn’t want to risk deleting and reinstalling all modules unless I had no other choice. Even though that approach could solve the error without troubleshooting, it also exposes me to other potential errors. The theme development was more than halfway complete, and it was clear that only imagemin was causing the error. I didn’t want to break gulp just to attempt to fix one module that was only failing at one specific task.
Although I’m not super active in on Discourse, I have notice many people taking the uninstall / reinstall approach as a blanket solution to many issues. One of the things that attracted me to Roots in the first place was the core contributors emphasis on understanding how and why things work. I hope more contributors will start sharing detailed solutions as we continue to grow.
Interesting viewpoint. I’m glad you’re taking the time to understand, that is definitely something that is expected when using Roots tools.
However I feel like I should also play devil’s advocate a bit and look at the other viewpoint. Mostly that vendor packages, IE. npm node_ modules, composer vendor, bower bower_components, one of the benefits is that they are third party code, something you can and should feel comfortable wiping out and getting fresh copies of.
Anyways, that’s just my opinion, but of course nothing wrong with figuring out the actual issue too
I agree with you @kalenjohnson. It also helps to enables people to experiment and try out new plugins! Sometimes the choosing the best approach simply depends on where you are in your project.