jablesauce jablesauce - 1 year ago 318
Android Question

Error at module.js:341 when trying to add android platform to ionic from command line

I am going to use the Ionic framework to work on hybrid app development, so I installed all the necessary dependencies (node.js, cordova, etc.) and followed their Getting started section. Step number 3 simply involves running the following command within the app directory:

> ionic platform add android

However midway during the execution I got the following error:

throw err;

Error: Cannot find module 'config-chain'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\Users\james.bonello\AppData\Roaming\npm\node_modules\cordova\node_modules\npm\lib\config\core.js:2:10)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)

I ran
> npm update
first and tried again to see if the update fixes any missing dependencies and such but the problem persisted.

So, as the error clearly states, the module 'config-chain' is missing so I next ran

> npm install config-chain

While that did install the module, the error somehow still persisted (identical to the previous one). I am not sure what to do next and I cannot understand why npm is not recognizing the 'config-chain' module now. Any ideas?

Answer Source

From what I can see, the missing package config-chain is a dependency of the global package cordova.

You should re-install cordova:

npm cache clean
npm uninstall cordova -g
npm install cordova -g

IF the problem persists, you have to manually install the package inside cordova's modules:

C:> cd Users\james.bonello\AppData\Roaming\npm\node_modules\cordova
C:> npm install config-chain
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download