Force ignores one npm / yarn setting dependency

My nodejs project uses some libraries. One pouchdb library will try to install quite a few dependencies. There is one leveldown call that will try to download the Node.js header from the Internet and then rebuild everything from scratch. Actually, I don't need leveldown at all. But their community offers me a private pouchdb plug and modify package.json to rule out any dependency I don't need.

Here is my general question for npm / narn people. Is it possible to prevent a specific library from loading when running npm install or yarn install ?

+5
source share
1 answer

No, exclude the exception from the installation dependencies.


However, in your case, you do not need a private pouchdb plug. PouchDB has custom builds published as npm packages: https://pouchdb.com/custom.html .

If you want to install pouchdb for use in a browser, npm install pouchdb-browser .

If you use other storage adapters (e.g. an adapter for internal memory), you can use npm install pouchdb-core instead. Please note that pouchdb-core does not include some features that ship with pouchdb .

  • If you need to use query() or viewCleanup() , you need to install pouchdb-mapreduce and pass it as a plugin.
  • If you need to use replicate() and sync() , you need to install pouchdb-replication and pass it as a plugin.

Usage example:

 const PouchDB = require('pouchdb-core') .plugin(require(WHATEVER_STORAGE_ADAPTER_YOU_ARE_USING)) .plugin(require('pouchdb-mapreduce')) .plugin(require('pouchdb-replication')); 
+3
source

Source: https://habr.com/ru/post/1270612/


All Articles