简体   繁体   English

在没有原始npm安装的情况下安装模块

[英]Install module without the original npm installation

There is a module that I want to try and make some changes to, for a test. 我想尝试对其中的模块进行一些更改以进行测试。

The code is here: 代码在这里:

https://github.com/BTMorton/angular2-grid https://github.com/BTMorton/angular2-grid

Right now to install this in my project I just need to type: npm install angular2-grid from my terminal. 现在要将其安装在我的项目中,我只需要输入:npm从我的终端安装angular2-grid。

My question is: 我的问题是:

If I downloaded the code from github and made some changes to it, 如果我从github下载代码并对其进行了一些更改,

How do I install it in my product and test it if my test changes are not on npm repo? 如果我的测试更改不在npm repo上,如何将其安装在产品中并进行测试?

Way 1: Relative Path 方式1:相对路径

  1. clone repo and edit the code, then build it. 克隆仓库并编辑代码,然后进行构建。
  2. Use it with relative path. 与相对路径一起使用。

Done! 做完了!

import { NgGridModule } from './angular2-grid';

Way 2: npm link 方式2: npm link

cd ~/projects/angular2-grid # go into the package directory (and edit and build)
npm link                    # creates global link
cd ~/projects/myProject     # go into some other package directory.
npm link angular2-grid      # link-install the package

Way 3: npm install <git repo> 方式3: npm install <git repo>

Fork and push changes to your repo and 分叉并将更改推送到您的仓库中

npm install --save <your repo address>

example, 例,

npm install --save https://github.com/YOURUSERNAME/angular2-grid

There are probably lot of other ways to deal with it. 可能还有许多其他方法可以处理它。 But these above will be enough for you. 但是以上这些对于您来说已经足够。

You can install npm modules locally. 您可以在本地安装npm模块。

Just use npm install file:/path/to/your/repo 只需使用npm install file:/path/to/your/repo

Alternately, you could fork the repo and then use a github link: 或者,您可以分叉存储库,然后使用github链接:

npm install github:yourname/angular2-grid.git

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM