【问题标题】:NPM : how to just run post-install?NPM:如何在安装后运行?
【发布时间】:2015-09-09 02:40:07
【问题描述】:

只是一个简单的问题:在我的 node.js 项目中,我怎么能只运行 postinstall 脚本,而不运行 install ?

仅供参考,这是我的 package.json :

{
  "name": "gestionclientjs",
  ...,
  "dependencies": {
    ...
  },
  "repository": {},
  "devDependencies": {
    ...
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "test": "grunt test",
    "postinstall" : "bower install && node ./app/server/dbSeed.js",
    "start": "node app/server/app.js"
  }
}

现在,我运行:

npm install

在我的项目中,但我想运行

npm postinstall

当我想要时(并且当我确定依赖项没问题时)。

【问题讨论】:

  • postinstall 仅在安装后运行:docs.npmjs.com/misc/scripts
  • 如果 npm-install 甚至记录了 postinstall(也许更多?)脚本正在运行,那就太好了...

标签: node.js npm package.json


【解决方案1】:

您可以使用npm run SCRIPTNAME 运行单个脚本条目:

$ npm run postinstall

【讨论】:

  • @nonox 它的特别之处在于它将在npm install 之后自动运行,但它也“只是”另一个脚本 :-)
  • 是的,当然……我不知道为什么我没想到
  • 我使用的是 npm 6.9.0 和 npm install 没有运行脚本 > postinstall。我必须使用这个答案命令才能让它运行。
  • 对于 npm 6.12.0,安装后自动运行。
  • @HarshSrivastava 有时手动运行 postinstall 很有用
猜你喜欢
  • 1970-01-01
  • 2018-05-24
  • 2016-09-18
  • 2017-11-05
  • 2023-03-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-29
相关资源
最近更新 更多