Search code examples
node.jstwitter-bootstrapdrupal-7gruntjs

Drupal 7. Bootstrap and Grunt


I'm trying to use Bootstrap and Grunt as a compiler. Installed everything to Drupal 7 site into my custom theme. I downloaded all its dependencies via npm install, this in turn added a node_modules folder. Now everything is fine when using grunt to compile, etc, my problem lies when you go to Drupal i get this warning...

Warning: opendir(sites/all/themes/custom/theme/vendor/bootstrap/node_modules/grunt-contrib-jade/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/optimist/node_modules/wordwrap,sites/all/themes/custom/lmax_hk/vendor/bootstrap/node_modules/grunt-contrib-jade/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/optimist/node_modules/wordwrap): The system cannot find the path specified. (code: 3) in file_scan_directory() (line 2118 of C:\Users\user\Documents\Program Files\xampp\htdocs\drupal\includes\file.inc).

I have no idea why and haven't found anything that might lead towards an answer.

I'm a newbie to Grunt and Nodejs.

Any help is much appreciated.


Solution

  • For future people finding this question - the issue seems to be gulp / grunt / npm .info files being parsed by Drupal core. Drupal 8 no longer uses .info files, but Drupal 7 will throw errors. There seems to be a patch underway for D7 core, but till then, the workaround is to create a post-install script to delete .info files in your package.json file.

    "scripts": {
        "postinstall": "find node_modules/ -name '*.info' -type f -delete"
      }
    

    Relevant thread on drupal.org: https://www.drupal.org/node/2329453#comment-9160735