2016-11-16 168 views
0

我正在开发一个node.js模块并结合使用该模块的更大的主节点node.js项目。npm模块开发依赖关系

在开发过程中,该模块位于主项目之外的文件夹中。因此,在开发过程中,不应该通过npm install进行安装。

对于生产部署,模块的存储库当然必须是依赖项的一部分。但是,正如我写的 - 它不应该在开发过程中安装。

是这样的:

/home/dev/ 
      master 
      module 

的package.json

{ 
    "name":"master" 
    "dependencies": { 
     "mymodule": "somewhere on git server" // ** only for production 
    } 
} 

回答

0

是的,你可以获取从GitHub模块以及本地机器的位置。

{ 
    "name": "master", 
    "dependencies": { 
     "git_module": "github_username/repo", // eg. LongHike/testApp (where LongHike is github account and testApp is repo) 
     "local_module": "file:../your_module" // local machine location (.. represents cd command) 
    } 
} 

希望这会帮助你!

+0

那么,我不想在本地机器上获取模块,因为它已经在那里。我只想把它拿来制作。 – LongHike

+0

然后''git_module“:”github_username/repo“'会帮助你 – SpunkyLive

+0

你如何管理模块只在生产环境中从git加载? 看,我的问题不是如何从git加载模块,而是如何防止它在开发过程中从git加载。 – LongHike