PouchDB with Quick Search plugin throws 'Error: Cannot find module "./lib/primes.json"'


I’ve successfully imported PouchDB in Ionic2RC3 but i can’t import pouchdb-quick-search plugin.

I’ve used import * as PouchDB from 'pouchdb'; and added typings from npm but for the plugin there is no typings by default. So, either adding:

declare module 'pouchdb-quick-search' {
  const plugin: PouchDB.Plugin;
  export = plugin;

into typings/globals/pouchdb-quick-search/index.d.ts file and then using:

import * as PouchQuickSearch from 'pouchdb-quick-search';

nor using directly (I’ve installed requirejs in my package.json):


works:(((( It keeps throwing Error: Cannot find module "./lib/primes.json"

Somehow I’ve made it work in RC1 but not anymore with RC3… What can i do to import this plugin? Any clue? @nolanlawson maybe?


To import json files you may need rollup-plugin-json.


I faced same problem today, when try to update from rc2 to rc3.

I think this is an issue of ionic app script about require json files in node_modules. I replace

var primes = requier "./lib/primes.json"


var primes = {
// here is JSON directly taken from ./lib/primes.json

Than error changes on other require json file, a replaced it too (this operation was needed for few modules in my app: diffie-hellman/browser.js, eliptic/lib/eliptic.js, parse-asn1/index.js) and my app start work again.

You can try this action in your app, or work with rc2


This might be related to this issue? Maybe using the nightly version of the Ionic Scripts would help?


Yeah. @ionic/app-scripts”: “0.0.46” solved a problem. Thanks.


For me, rollup-plugin-json plugin didn’t help. Probably because of Webpack related issues… I was about to try @snikh’s solution by injecting every json file. But i didn’t want to use a dirty hack like that. Then I gave up PouchDB and started to use LokiJS + localForage (for persistence) as in this tutorial. These kinds of problems are really annoying.

After two days of research, I’ve gave up :frowning: Whole coding process is a good xp indeed; trying to develop a real product with an unstable tool in RC version is a big risk, I learned :slight_smile: