Reputation: 941
I am developing a package (library) at the same time as the application that uses it (also a package) and I would like to use the local library if available as sibling of the application, and otherwise download the latest release from github.
I tried having two references in dependencies
and optionalDependencies
, hoping that a failure of the latter would still use the specification in the former, but that doesn't work. The package is skipped.
Is this possible at all? Or maybe there are other ways to solve the problem? Maybe some creative use of the script hooks?
Upvotes: 1
Views: 642
Reputation: 504
Maybe what you can do is to publish it on GitHub and in your package.json you can call directly from the repository something like this:
"dependencies": {
"mongoose-cipher": "git+ssh://[email protected]:estrada9166/mongoose-
cipher.git"
}
or
"dependencies": {
"mongoose-cipher": "git+https://[email protected]:estrada9166/mongoose-
cipher.git"
}
also you can specify the release, in case your repository has one, something like:
"dependencies": {
"mongoose-cipher": "git+ssh://[email protected]:estrada9166/mongoose-
cipher.git#v0.0.7"
}
you can create a private repository with your package and by this way it is safe!
To install from GitHub: npm install <git repo url>
also you can add your package on the node_modules folder and add the dependency on your package.json
but personally I prefer to publish to GitHub and install it on my project, is easier.
Upvotes: 1