简体   繁体   中英

Cannot find module 'which' - Cordova android

I am trying to build my cordova build by executing below command

cordova -d build android

but I am necountering below error.

module.js:340
throw err;                                                                                                       
Error: Cannot find module 'which'                              
at Function.Module._resolveFilename (module.js:338:15)     
at Function.Module._load (module.js:280:25)                
at Module.require (module.js:364:17)                       
at require (module.js:380:17) 

anyone knows the reason? I checked that I have my ANT_HOME/ANDROID_HOME in my path but I am not sure what is the reason behind the error though.

I am running windows 7 64 bit by the way

Similar to the answer to this question , the solution for me was to

$cordova platform remove android
$cordova platform add android

对我来说,这看起来像某种丢失的节点模块..你试过了吗?

npm install -g which

It seems your nodejs installation is broken. It occurs when install/update from yum (for sample) failed. For my case, I simply deleted the broken modules from "/usr/lib/node_modules" and perfomed an install.

This happened to me today, too. I installed which but then the module chalk was missing.

Doing an npm update installed all the packages missing and it seems to be the right way to resolve. (But why this happened is a mystery as node was doing fine yesterday and I cannot recall any relevant changes.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM