TLDR: Delete the node_modules folder!
Recently I added a Drush command for us to use to easily get Grunt running from any folder in the docroot. It works great! just a little
and off we go!
It’s a pretty simple, and builds off a lot of work I did making a drush command for us to engage visual regression with BackstopJS. (checks for dependencies, grabs git branch name, passes variable flags into JS) I’ll make a different post about that sometime.
Anyway, since all the grunt files live in the theme folder, the most important part was telling drush where that was, so it we could run npm install, and get everything running locally, including live reload, which is awesome.
We’re still using Drupal 7 and by using :
$path_to_grunt = drupal_get_path('theme', 'mc_main');
Now, we can tell drush where to run grunt for us! Of course, we did need to make sure to change the working directory, so the command would actually run there,
So then we just run`
, with a few checks, and we’re good to follow that up with :
Ok, but then I found running drush on things started crashing my PHP with SEGFAULTS all over the place. ugh!
What was going on? How do I fix it, I just wanted to test our latest release and I’m looking at error logs and …
Ok, after some research, and digging through my bash/zshrc files, and getting some strange errors from the command line after trying to
drush updb like :
sh: line 1: 36818 Segmentation fault: 11 /Applications/DevDesktop/php5_5_x64/bin/php /Applications/DevDesktop/tools/vendor/drush/drush/drush.php --php=/Applications/DevDesktop/php5_5_x64/bin/php --backend=2 --root=/Users/me/sites/devdesktop/mcmain-dev/docroot --uri=http://default pm-updatestatus 2>&1 pm-updatestatus failed.
I mean, what? Why is drush trying to even use php 5_5 at all? where is that setting? (I still don’t know.)
I finally ran across this article: Drupal’s Drush Segmentation fault:11
Arvind explains that when npm install runs on your package.json file and creates the node_modules folder in your theme folder…
Drupal freaks out because many node modules include their own .info files. Drupal is looking for only one .info file per theme to exist.
He provides a solution to add a postinstall line to your package.json to remove all the additional .info files inside the node_modules folder.
but! short term, super simple solution for anyone who is experiencing drush weirdness after running an install on a package.json
At least while you’re trying to run other drush commands, feel free to get your grunt on when you’re done.