lein-npm icon indicating copy to clipboard operation
lein-npm copied to clipboard

How to add `npm prune` in a hook before installing?

Open binarykitchen opened this issue 10 years ago • 6 comments

Hello guys

With this plugin npm install is invoked when calling lein deps. How can I add a npm prune before npm install? Is there a hook for that I can add in the project.clj file?

binarykitchen avatar Feb 11 '15 22:02 binarykitchen

Mmmm, not that I am aware of. Can you run npm prune on its own? Is there a reason to not keep the commands separate?

RyanMcG avatar Jun 23 '15 03:06 RyanMcG

never mind this one, i solved this within package.json:

  "scripts": {
    "preinstall": "npm prune",
  },

but unfortunately lein-npm does not honour existing package.json's when running lein deps ...

binarykitchen avatar Jun 23 '15 03:06 binarykitchen

Can you use :nodejs {:scripts {:preinstall "npm prune"}} in your project.clj instead?

The purpose of lein-npm is to produce a package.json so it makes sense to not use it. From the README:

You can execute npm commands that require the presence of a package.json file using the lein npm command.

Does that help?

RyanMcG avatar Jun 23 '15 04:06 RyanMcG

Yeah, I could. I just do not want to move this to project.clj because we are using pm2 for deployment and it requires package.json to exist permanently.

binarykitchen avatar Jun 23 '15 04:06 binarykitchen

Would #35 help? I'd appreciate your input.

RyanMcG avatar Aug 14 '15 01:08 RyanMcG

i am afraid i cannot help because i do not understand clojure :/

binarykitchen avatar Aug 14 '15 04:08 binarykitchen