My nodejs project uses some libraries. One library pouchdb
will try to install quite a lot of dependencies. There is one called leveldown
, which will try to download Node.js header from Internet and then rebuild everything from scratch. Actually I don't need the leveldown
at all. But their community suggest me to privately fork a pouchdb
and the modify the package.json to exclude any dependency I don't need.
Here is my general question to npm/yarn folks. Is it possible to prevent particular library from being downloaded, while running npm install
or yarn install
?
No, it's not possible to exclude a sub-dependency from the installation.
However, in your case, you don't need to privately fork pouchdb
. PouchDB has custom builds published as npm packages: https://pouchdb.com/custom.html.
If you want to install pouchdb for use in-browser, npm install pouchdb-browser
.
If you're using other storage adapters (like the in-memory adapter), you may want to npm install pouchdb-core
instead. Note that pouchdb-core
doesn't include some functions that ship with pouchdb
.
query()
or viewCleanup()
, you need to install pouchdb-mapreduce
and pass it as a plugin.replicate()
and sync()
, you need to install pouchdb-replication
and pass it as a plugin.Example usage:
const PouchDB = require('pouchdb-core')
.plugin(require(WHATEVER_STORAGE_ADAPTER_YOU_ARE_USING))
.plugin(require('pouchdb-mapreduce'))
.plugin(require('pouchdb-replication'));