Reputation: 60855
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".
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:
Upvotes: 31
Views: 35389
Reputation: 5612
In newer versions of npm (6+), its now possible to alias the module name with
npm i <alias_name>@npm:<original_package_name>
Upvotes: 37
Reputation: 835
Since [email protected]
you could install package under a custom module name. [email protected]
introduces support for package aliases.
To install a tarball under custom module name use custom-name@tarball-url
argument, e.g. install specific express
tarball as my-express
module:
npm i my-express@https://github.com/expressjs/express/archive/4.16.3.tar.gz
This feature also allows to alias packages published to npm registry:
npm i express@npm:@my-scope/express
Upvotes: 32
Reputation: 14434
there was an issue filed on the npm-github repository requesting that feature.
read on here: https://github.com/npm/npm/issues/2943
Upvotes: 10
Reputation: 5295
Specfically for browser you can add an alias in 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.
Upvotes: 1
Reputation: 8620
You could do this:
name
in its package.json
to @me/mymoduleTemp
(you could skip steps 1 and 3 by editing the tarball in place with vim mymoduleTemp.tgz
)mymoduleTemp.tgz
npm publish mymoduleTemp.tgz
(with --access public
unless you want it to be restricted)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.
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.
Upvotes: 1