Is it possible provide two version of a same package npm ?
I have a git repository with :
MyRepo
|- library
|- FolderToHide
|- package.json
|- .npmignore
File package.json is containing :
{
"name": "myRepo",
"repository": {
"type": "git",
"url": "https://somewhere"
},
...
}
How can I configure my package to create a version with FolderToHide
and another without ?
I want to have something like this :
MyRepo2
|- node_modules
|- myRepo
|- library
MyRepo3
|- node_modules
|- myRepo
|- library
|- FolderToHide
MyRepo3 can be used as debug repository, maybe is it possible to create a debug version for a package ?
If you want it to be single npm package, e.g.
my-package
(not two separate packagesmy-package
andmy-package-with-hidden-folder
) you can use dist-tags for this.FolderToHide
to your.npmignore
.-limited
to version of your package inpackage.json
(so it looks like2.1.0-limited
) and runnpm publish --tag limited
(you can replacelimited
with any name you want). This will publish version of package withoutFolderToHide
with taglimited
.FolderToHide
from.npmignore
-limited
inpackage.json
to-full
and runnpm publish --tag full
(again,full
can be any name you wish). This will publish new version of package withFolderToHide
included.Then, when you want to install your package in another project you run either
npm install my-package@limited
ornpm install my-package@full
.Alternatively, you can decide to have one of versions as default option. In this case you should omit dist-tag for it. So instead of
npm publish --tag full
you just runnpm publish
. This will (implicitly) assign taglatest
to published version. And when you install package without specifying tag (npm install my-package
), npm will use package withlatest
tag.