I want to install a specific revision from a github tarball named something like "mymodule" and name it something like "mymoduleTemp", and then load a potentially different version of it that will take the real name "mymodule".
我想从名为“mymodule”之类的github tarball安装一个特定的版本,并将其命名为“mymoduleTemp”,然后加载一个可能采用真实名称“mymodule”的可能不同的版本。
So, how do I do the first thing? I'm looking for something like:
那么,我该如何做第一件事呢?我正在寻找类似的东西:
npm install https://github.com/me/mymodule/tarball/someTag -name mymoduleTemp
Is there any way to do that? A nice-to-have:
有没有办法做到这一点?一个很好的:
- If mymodule already exists, it doesn't get clobbered when mymoduleTemp is installed (ie ideally the process wouldn't be to install as mymodule then rename the folder)
如果mymodule已经存在,那么在安装mymoduleTemp时它不会被破坏(理想情况下,该进程不会作为mymodule安装,然后重命名该文件夹)
3 个解决方案
#1
6
there was an issue filed on the npm-github repository requesting that feature.
npm-github存储库中存在一个问题,要求该功能。
read on here: https://github.com/isaacs/npm/issues/2943
请阅读:https://github.com/isaacs/npm/issues/2943
#2
1
You could do this:
你可以这样做:
- Get the tarball and extract it
- Change the
name
in itspackage.json
to@me/mymoduleTemp
(you could skip steps 1 and 3 by editing the tarball in place withvim mymoduleTemp.tgz
) - Compress it to
mymoduleTemp.tgz
- Run
npm publish mymoduleTemp.tgz
(with--access public
unless you want it to be restricted) - In your main project, run
npm install @me/mymoduleTemp
获取tarball并提取它
将package.json中的名称更改为@ me / mymoduleTemp(您可以通过使用vim mymoduleTemp.tgz编辑tarball来跳过步骤1和3)
将其压缩到mymoduleTemp.tgz
运行npm发布mymoduleTemp.tgz(除非你想要限制,否则使用--access public)
在您的主项目中,运行npm install @ me / mymoduleTemp
I'd recommend publishing it as a scoped package, because if you publish it as unscoped mymoduleTemp
, then no one else can use that name.
我建议将它作为范围包发布,因为如果你将它发布为unscoped mymoduleTemp,那么没有其他人可以使用该名称。
If you think even publishing scoped packages is polluting the npm registry, then you can just put the new tarball on your own private server (or in GitHub, or wherever) and install it via URL.
如果您认为即使发布范围包也会污染npm注册表,那么您可以将新的tarball放在您自己的私有服务器上(或者在GitHub中,或者在任何地方)并通过URL安装它。
#3
0
Specfically for browser you can add an alias in package.json
特别是对于浏览器,您可以在package.json中添加别名
https://github.com/defunctzombie/package-browser-field-spec
eg:
{
....
"browser": {
"someTag": "mymoduleTemp"
}
}
This also works for "react-native" with metro bundler. I've never tested with webpack bundles.
这也适用于地铁捆绑器的“react-native”。我从未测试过webpack捆绑包。
#1
6
there was an issue filed on the npm-github repository requesting that feature.
npm-github存储库中存在一个问题,要求该功能。
read on here: https://github.com/isaacs/npm/issues/2943
请阅读:https://github.com/isaacs/npm/issues/2943
#2
1
You could do this:
你可以这样做:
- Get the tarball and extract it
- Change the
name
in itspackage.json
to@me/mymoduleTemp
(you could skip steps 1 and 3 by editing the tarball in place withvim mymoduleTemp.tgz
) - Compress it to
mymoduleTemp.tgz
- Run
npm publish mymoduleTemp.tgz
(with--access public
unless you want it to be restricted) - In your main project, run
npm install @me/mymoduleTemp
获取tarball并提取它
将package.json中的名称更改为@ me / mymoduleTemp(您可以通过使用vim mymoduleTemp.tgz编辑tarball来跳过步骤1和3)
将其压缩到mymoduleTemp.tgz
运行npm发布mymoduleTemp.tgz(除非你想要限制,否则使用--access public)
在您的主项目中,运行npm install @ me / mymoduleTemp
I'd recommend publishing it as a scoped package, because if you publish it as unscoped mymoduleTemp
, then no one else can use that name.
我建议将它作为范围包发布,因为如果你将它发布为unscoped mymoduleTemp,那么没有其他人可以使用该名称。
If you think even publishing scoped packages is polluting the npm registry, then you can just put the new tarball on your own private server (or in GitHub, or wherever) and install it via URL.
如果您认为即使发布范围包也会污染npm注册表,那么您可以将新的tarball放在您自己的私有服务器上(或者在GitHub中,或者在任何地方)并通过URL安装它。
#3
0
Specfically for browser you can add an alias in package.json
特别是对于浏览器,您可以在package.json中添加别名
https://github.com/defunctzombie/package-browser-field-spec
eg:
{
....
"browser": {
"someTag": "mymoduleTemp"
}
}
This also works for "react-native" with metro bundler. I've never tested with webpack bundles.
这也适用于地铁捆绑器的“react-native”。我从未测试过webpack捆绑包。