-1

I'm getting some rather unexpected behaviour when installing (a private) dependency.

For questions sake lets assume I have two packages:

{
  "name": "Package_A",
   ....
  "dependencies": {
    "grunt": "~0.4.2",
    "Package_B": ""      
  }
}

And

{
  "name": "Package_B",
  "scripts": {
    "install": "grunt"
  },
   ....
  "dependencies": {
    "grunt": "~0.4.2",
    "grunt-contrib-clean": "~0.5.0"      
  }
}

Now when I run npm install on (a fresh) Package_A, Package_B installs with grunt-contrib-clean as a dependency and runs grunt (which uses clean). It all works fine.

Now as soon as I add grunt-contrib-clean to Package_A dependencies and run install (fresh copy again) fails.
the npm install script runs grunt, and grunt cannot find grunt-contrib-clean:

Local Npm module "grunt-contrib-clean" not found. Is it installed?

I'm not really sure where to go from here. I was wondering if I'm having a similar issue to NPM doesn't install module dependencies. But I don't know enough about npm or grunt to tell.

Community
  • 1
  • 1
MrJD
  • 1,879
  • 1
  • 23
  • 40
  • I just tried changing the Package_B install script to `npm install && grunt package`, it installed the dependencies but then infinitely loops over the command without doing anything :/ – MrJD Feb 19 '14 at 22:45
  • ^^ thats because npm install is calling the install script :/ – MrJD Feb 19 '14 at 22:51

1 Answers1

0

Got it!
Changing the script from install to prepublish works

 "scripts": {
    "prepublish": "grunt package"
  },

Must be something to do with the order of operations when installing. Quirky.


Damn it

(Update)

Npm doesn't run prepublish when installing from a git repo (when it probably should).

Community
  • 1
  • 1
MrJD
  • 1,879
  • 1
  • 23
  • 40