Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have npm module with following package.json

{
  "name": "my-app",
  "version": "0.0.0",
  "scripts": {
    "prepublish": "bower install",
    "build": "gulp"
  },
  "dependencies": {
    "express": "~4.0.0",
    "body-parser": "~1.0.1"
  },
  "devDependencies": {
    "gulp": "~3.6.0",
    "bower": "~1.3.2"
  }
}

When I deploy my app to production, I don't want install devDependecies, so, I run npm install --production. But in this case, prepublish script is called, but it doesn't need to, because I use CDN links in production.

How to call postinstall script only after npm install but not after npm install --production?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
613 views
Welcome To Ask or Share your Answers For Others

1 Answer

Newer npm (& Yarn) versions include support for the prepare script that is run after each install run but only in development mode. Also, the prepublish is deprecated. This should be enough:

{
  scripts: {
    "prepare": "bower install"
  }
}

Docs: https://docs.npmjs.com/misc/scripts


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...