gradle-node-plugin
gradle-node-plugin copied to clipboard
setting nodeModulesDir doesn't change node_modules path
When I set nodeModulesDir = file("${project.buildDir}") in my build.gradle the node_modules folder still ends up in ${projectDir} and not ${project.buildDir}.
I just created a testcase and it seems to work as expected https://github.com/node-gradle/moved_node_modules
Though I'm guessing that you really want package.json in / and node_modules located in /build/node_modules but looking at https://docs.npmjs.com/files/folders.html it doesn't seem like that's how npm works.
Though I'm guessing that you really want
package.jsonin/andnode_moduleslocated in/build/node_modules
Yeah, that's what I was going for so that the node_modules for the gradle build wouldn't conflict with the one created if you run yarn directly.
Hmm, can NODE_PATH be used for forcing an alternate node_modules path? Yarn seems to at least be able to override it for the install using the --modules-folder flag but I couldn't figure out how to get the env set up properly for running scripts.
It sounds like NODE_PATH would work slightly differently https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
But why do you want them to be separate? is it really a conflict? I mean they're both building the same thing, so they should have the same result
is it really a conflict?
So it's mostly an issue if the version of node being used by gradle differs from the one used when not using gradle as package c extensions seem to sometimes be version specific.
It sounds like in your case you want download = false aka "use local node", that way you shouldn't have any mismatch.
If you don't have or want node on your CI environment you could do something like download = System.getenv().containsKey("CI") and set CI=true
Well I was wanting to use the downloading feature for compilation of production asset bundles to ensure reproducibility. I only really wanted to use the local node for running webpack-dev-server.
Hmm, I guess you could set nodeModulesDir to a directory in build, make the install task depend on a Copy task which copies your package.json there (along with the sources necessary to build the application).
But all-in-all it'd probably be easier to set up some CI to do the production build
Is this issue fixed?