将自制程序依赖项添加到npm包

时间:2016-07-06 17:45:21

标签: javascript json node.js npm homebrew

我想在我试图创建的npm包中添加一个自制的依赖项,我正在使用drafter-HEAD。有没有人有关于如何做到这一点的想法?

1 个答案:

答案 0 :(得分:3)

要想到几件事。如果有依赖关系,你可以将依赖关系指向GitHub仓库。

{
  "name": "my-project-name",
  "version": "0.0.1",
  "description": "My Description Here",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "The Best Developer Ever",
  "license": "MIT",
  "dependencies": {
    "express" : "github:expressjs/express",
    "anyRepo" : "github:userName/projectName"
  }
}

您还可以在package.json文件中创建自定义命令。称之为brew(这与实际的命令行工具不同),你可以在那里运行脚本

{
  "name": "my-project-name",
  "version": "0.0.1",
  "description": "My Description Here",
  "main": "main.js",
  "scripts": {
    "brew" : "sudo brew install package-name(s)-here",
    "any-name-here" : "echo Any command can go here"
  },
  "author": "The Best Developer Ever",
  "license": "MIT",
  "dependencies": {
    "express" : "github:expressjs/express",
  }
}

然后你运行

  

npm run brew

该命令中的任何脚本都将运行(也就是安装自制程序依赖项)。我相信这应该是你正在寻找的。

- juan

编辑 --------------------------------------- -------------------------------------------------- ----------------------------

对不起,我不小心给了错误的命令。您应该运行npm run brew NOT npm brew