无法修改和测试分叉的GitHub库 - npm ERR!版本未找到 [英] Unable to modify and test a forked GitHub library - npm ERR! version not found

查看:128
本文介绍了无法修改和测试分叉的GitHub库 - npm ERR!版本未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对所有这个Github分叉请求生命周期都不感兴趣。我想要做的是在提交拉取请求之前分叉一个存储库,进行一些更改并在项目上尝试它们。



我已经分叉回购并修改了它,但是我我无法测试它。



假设我将package.json中的分叉库的版本增加到了1.0。 1 。然后我执行 npm install -g



现在我想在另一个 test-project ,所以我使用新的固定版本的库(1.0.1)更新了package.json devDependencies信息。



现在我在 test-project 中运行 npm install ,但是我得到这个错误:

  npm ERR!版本未找到:forked-library@1.0.1 

我曾期待自从我在全球安装它以来,这个项目会从我的本地npm缓存(我可以看到1.0.1版本)解决它,但它似乎是在npm在线存储库中查找它。

npm install 命令将总是试图从npm注册表中找到一个已发布的版本。因为你还在开发中,所以它不会在那里找到它。



要解决这个问题,你可以使用 npm link 命令 - 它将为您的本地开发版本设置一个符号链接。



以下是如何使用它:

 #CD到分支库项目
cd〜/ forked-library

#调用npm链接创建一个全局链接
npm link

#CD到测试项目
cd〜/ test-project

#调用npm链接将开发版本链接到这个项目
npm link forked-library

完成之后,您应该有一个符号链接到您的本地 forked-library 文件夹从 test-project / node_modules 文件夹。

这将允许您在不释放它的情况下使用开发版本。您可以在分叉的库中进行更改,它们将立即在您的测试项目中可见。



以下是 npm链接文档


I am a noobie with all this Github forking-pull-request lifecycle. What I want to do is fork a repository, make some changes and try them on a project before submitting a pull request.

I already forked the repo and modified it but I am not able to test it.

Let's suppose I increased the version of the forked library in package.json to 1.0.1. Then I execute npm install -g.

Now I want to test it in another test-project, so I update the package.json devDependencies info with the new fixed version of the library (1.0.1).

Now I run npm install in test-project but I get this error:

npm ERR! version not found: forked-library@1.0.1

I was expecting that since I installed it globally, this project would resolve it from my local npm cache (where I can see the 1.0.1 version), but it seems to be looking for it in the npm online repository.

解决方案

The npm install command will always try to find a released version from the npm registry. Since you're still in development, it will not find it there.

To work around this, you can use the npm link command - which will set up a symbolic link to your local development version.

Here's how to use it:

# CD to the forked-library project
cd ~/forked-library

# Call npm link to create a global link
npm link

# CD to the test project
cd ~/test-project

# Call npm link to link the development version to this project
npm link forked-library

After doing that, you should have a symbolic link to your local forked-library folder from the test-project/node_modules folder.

This will allow you to use the development version without releasing it. You can make changes in the forked library and they will be visible immediately in your test project.

Here's the npm link documentation.

这篇关于无法修改和测试分叉的GitHub库 - npm ERR!版本未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆