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
?
To skip Installation of devDepenencies pass --production flag to npm install ,with the --production flag(or NODE_ENV environment variable set to production ) npm will not install modules listed in devDependencies." To make any module to be part of devDependencies pass --dev while installing.
If you run yarn remove [package] it will remove the package from node_modules and also from the yarn. lock file. If you manually delete from package. json and then run yarn install , the deleted package is not installed and the yarn.
How to prevent npm install with an unsupported Node. js version. It turns out you can add a local npm configuration file ( . npmrc ) to your module/project root and explicitly turn on strict Node.
Execute npm install someDependency --save-optional to install a package as an optional dependency. The installed package will be put into optionalDependencies . When you want to avoid installing optional dependencies, you can execute npm ci --no-optional (e.g. on CI tools like GitLab CI).
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'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With