railsware / bozon

🛠 Command line tool for building, testing and publishing modern Electron applications
MIT License
758 stars 52 forks source link

ModuleNotFoundError: dependency already declared in package.json not usable #65

Open mtenrero opened 4 years ago

mtenrero commented 4 years ago

Hello, this issue would be probably considered as a newbie bozon user question.

I'm having problems using dependencies declared in package.json in the main process js file:

"dependencies": {
    "pouchdb-adapter-leveldb": "^7.1.1",
    "rxdb": "^8.7.5"
  },
  "devDependencies": {
    "bozon": "0.10.7",
    "mocha": "^7.0.0",
    "spectron": "^9.0.0"
  },

The error given is:

× Webpack failed to bundle application
[
  ModuleNotFoundError: Module not found: Error: Can't resolve 'pouchdb-adapter-leveldb' in 'C:\Users\marcostm\Documents\personal\mivet_bozon\src\main'
      at C:\Users\marcostm\scoop\persist\nodejs\bin\node_modules\bozon\node_modules\webpack\lib\Compilation.js:925:10
      at C:\Users\marcostm\scoop\persist\nodejs\bin\node_modules\bozon\node_modules\webpack\lib\NormalModuleFactory.js:401:22
      at C:\Users\marcostm\scoop\persist\nodejs\bin\node_modules\bozon\node_modules\webpack\lib\NormalModuleFactory.js:130:21
      at C:\Users\marcostm\scoop\persist\nodejs\bin\node_modules\bozon\node_modules\webpack\lib\NormalModuleFactory.js:224:22
      at C:\Users\marcostm\scoop\persist\nodejs\bin\node_modules\bozon\node_modules\neo-async\async.js:2830:7
      at C:\Users\marcostm\scoop\persist\nodejs\bin\node_modules\bozon\node_modules\neo-async\async.js:6877:13
      at C:\Users\marcostm\scoop\persist\nodejs\bin\node_modules\bozon\node_modules\webpack\lib\NormalModuleFactory.js:214:25
      at C:\Users\marcostm\scoop\persist\nodejs\bin\node_modules\bozon\node_modules\enhanced-resolve\lib\Resolver.js:213:14
      at C:\Users\marcostm\scoop\persist\nodejs\bin\node_modules\bozon\node_modules\enhanced-resolve\lib\Resolver.js:285:5
      at eval (eval at create (C:\Users\marcostm\scoop\persist\nodejs\bin\node_modules\bozon\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:13:1)
  resolve 'pouchdb-adapter-leveldb' in 'C:\Users\marcostm\Documents\personal\mivet_bozon\src\main'
    Parsed request is a module
alchaplinsky commented 4 years ago

@mtenrero Try rm -rf node_modules and npm install. Looks like dependency is declared in package.json, but is not present in node_modules.

mtenrero commented 4 years ago

@mtenrero Try rm -rf node_modules and npm install. Looks like dependency is declared in package.json, but is not present in node_modules.

I've also done that, It seem to not be detecting the dependencies....

Probably would be related with webpack?

alchaplinsky commented 4 years ago

What do you have in your 'webpack.config.js'?

mtenrero commented 4 years ago

Anything..

module.exports = {
  renderer: {},
  preload: {},
  main: {}
}
alchaplinsky commented 4 years ago

Ok, so webpack should look for imported modules in node_modules directory. Can you confirm that there's pouchdb-adapter-leveldb folder in ./node_modules?

fawzywassel commented 4 years ago

i have same bug ... any solution ... please

andrewo0 commented 3 years ago

ModuleNotFoundError: Module not found: Error: Can't resolve 'pouchdb-adapter-leveldb' so if the file is in your node_modules the only issue is your not importing it the correct way