james emanon
james emanon

Reputation: 11837

Issues with Grunt loadNpmTasks and not finding the module

I am new to Grunt. I have my grunt (verified version and such) and I see my needed Npmtasks in my "node_modules" folder. But, when I try to run the grunt, it fails because the task module can't be found.

grunt default -v

I have my node_modules installed in my drive:

C:\Users\NoBody\node_modules

Usually, this isn't an issue. BUT, it appear that where I am doing my dev:

C:\users\Nobody\Desktop\Development\GruntExamples\

can't locate my needed NpmTask modules. When I move the files into: C:\Users\Nobody -- everything works.. But, I don't want to do my dev there.

I tried adding the path to NpmTaks like so:

grunt.loadNpmTasks("../../../../grunt-contrib-clean");

I tried a few other "paths", nothing is working. Is there a "path" declaration I can add to my grunt file that will let my task resolve where it needs to?

note: I tried npm install grunt-contrib-clean --save-dev (no luck), I tried grunt-contrib-clean -g (no luck)..

But just like I mentioned. If I move my files inside the same root dir that my node_modules sit, it works... but again, I don't want to do my dev here.

Please advise.

Upvotes: 1

Views: 195

Answers (1)

meilke
meilke

Reputation: 3280

Using symbolic links seems to be an option (How to make Grunt Deploy use global NPM modules instead of local ones), although I have never tried it.

However, I would advise against using a global node_modules location. My reasoning:

  • Local copies of your dependencies do not affect each other. Updating karma, for instance, in one of your code bases does not affect the others. Trying out a new version of grunt will not harm anybody else.
  • Some people say that you also should ship your node_modules folder (link) - a thing that you can only do if you have a local copy

Upvotes: 1

Related Questions