Error when importing Pouchdb
See original GitHub issueHello,
I’m trying to use Pouchdb with this boilerplate, however, whenever I add import PouchDB from 'pouchdb';
anywhere, I immediately get the following error:
WARNING in ./~/levelup/lib/util.js [0] Module not found: Error: Cannot resolve module 'leveldown/package' in /home/samir/Sites/school/node_modules/levelup/lib [0] @ ./~/levelup/lib/util.js 36:23-51 [0] [0] WARNING in ./~/bindings/bindings.js [0] Critical dependencies: [0] 76:22-40 the request of a dependency is an expression [0] 76:43-53 the request of a dependency is an expression [0] @ ./~/bindings/bindings.js 76:22-40 76:43-53 [0] [0] WARNING in ./~/bindings/README.md [0] Module parse failed: /home/samir/Sites/school/node_modules/bindings/README.md Unexpected token (2:3) [0] You may need an appropriate loader to handle this file type. [0] SyntaxError: Unexpected token (2:3) [0] at Parser.pp.raise (/home/samir/Sites/school/node_modules/webpack/node_modules/acorn/dist/acorn.js:923:13) [0] at Parser.pp.unexpected (/home/samir/Sites/school/node_modules/webpack/node_modules/acorn/dist/acorn.js:1490:8) [0] at Parser.pp.parseExprAtom (/home/samir/Sites/school/node_modules/webpack/node_modules/acorn/dist/acorn.js:333:12) [0] at Parser.pp.parseExprSubscripts (/home/samir/Sites/school/node_modules/webpack/node_modules/acorn/dist/acorn.js:228:19) [0] at Parser.pp.parseMaybeUnary (/home/samir/Sites/school/node_modules/webpack/node_modules/acorn/dist/acorn.js:207:17) [0] at Parser.pp.parseExprOp (/home/samir/Sites/school/node_modules/webpack/node_modules/acorn/dist/acorn.js:174:41) [0] at Parser.pp.parseExprOp (/home/samir/Sites/school/node_modules/webpack/node_modules/acorn/dist/acorn.js:176:19) [0] at Parser.pp.parseExprOps (/home/samir/Sites/school/node_modules/webpack/node_modules/acorn/dist/acorn.js:156:15) [0] at Parser.pp.parseMaybeConditional (/home/samir/Sites/school/node_modules/webpack/node_modules/acorn/dist/acorn.js:136:19) [0] at Parser.pp.parseMaybeAssign (/home/samir/Sites/school/node_modules/webpack/node_modules/acorn/dist/acorn.js:112:19) [0] @ ./~/bindings ^\.\/.*$
And the app devtools shows the following: validate.js?c7dd:17Uncaught Error: define cannot be used indirect
After a long search I stumbled on the following https://github.com/pouchdb/pouchdb/issues/3647 but unfortunately the suggested solution does not work for me.
How do I fix this? I’m pretty much useless when it comes to Webpack, hence the question. Thank you, and good evening
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (1 by maintainers)
Hello again, Tried your approach, I’m still encoutering the same error:
validate.js?c7dd:17Uncaught Error: define cannot be used indirect
The terminal however shows a clean bundle this time.
My webpack.config.base.js
Edit: After more trial and error, It seems to be fixed. I just added this line to your solution:
noParse: /node_modules\/json-schema\/lib\/validate\.js/
Resulting in this final webpack.config.base.js file :
Thank you for sharing this!