Thursday, May 4, 2017

Grails 3 accessing node_modules

Leave a Comment

Starting on a Grails 3 app and trying to use a node plugin. My custom javascript is located under grails-app/assets/javascripts but when I run gradle build it installs the node_modules folder under my root project directory. This folder has all my JS libraries and I'm unable to access them from my within grails-app/assets/javascripts.

Is there a way to install node_modules under grails-app? Do I need to specify the directory in my build.gradle?

Here's my node and grunt plugins in my build.gradle.

classpath "com.moowork.gradle:gradle-node-plugin:0.12" classpath "com.moowork.gradle:gradle-grunt-plugin:0.12"

apply plugin:"com.moowork.node" apply plugin:"com.moowork.grunt"

1 Answers

Answers 1

You can change the location of the node_modules folder.

First, upgrade the node and grunt plugins to version 0.13

classpath "com.moowork.gradle:gradle-node-plugin:0.13" classpath "com.moowork.gradle:gradle-grunt-plugin:0.13" 

Second, add the following to your build.gradle file:

node { nodeModulesDir = file("grails-app") } 

This will create the node_modules folder under grails-app (i.e. grails-app/node_modules)

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment