如何从另一个模块的依赖项引用模块

时间:2013-05-14 08:51:21

标签: node.js dependencies node-modules

我有一个包含2个依赖项的项目:

{
  dependencies: {
    "nommon": "*",
    "descript": "*"
  }
}

模块描述本身取决于模块nommon。 我希望nommon引用与描述依赖项中的相同。

所以,我想要的就是这样:

{
  dependencies: {
    "nommon": "./decript/node_modules/nommon",
    "descript": "*"
  }
}

我知道npm link,但这是一个手动操作。

我想要一个package.json依赖声明,以便在npm install之后我得到一个正在运行的包。

目前我通过手动添加符号链接解决了这个问题。

1 个答案:

答案 0 :(得分:0)

如果我理解得很好: 描述项目需要nommon运行,你不想使用npm链接?

最简单的方法是将模块nommon发布到npm注册表。 在这种情况下,您将像任何其他模块一样设置依赖项。

如果您不希望模块成为公共模块,则可以在服务器上存储nommon的tarball,并将url设置为解析tarball的url。你也可以使用git仓库

看看这里:

https://npmjs.org/doc/developers.html

在什么是包

我希望这可以帮到你

Ostro

相关问题