Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic 4 platform add android error code ENOLOCAL

I removed my android platform on my ionic project and tried to re-install it but I keep receiving npm ERR! code ENOLOCAL . here is the error when I type platform add android:

(node:3880) UnhandledPromiseRejectionWarning: CordovaError: Error: cmd: Command failed with exit code 1 Error output:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "android" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\RMT016\AppData\Roaming\npm-cache\_logs\2018-09-26T08_08_46_485Z-debug.log
    at C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-fetch\index.js:105:29
    at _rejected (C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:864:24)
    at C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:890:30
    at Promise.when (C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:1142:31)
    at Promise.promise.promiseDispatch (C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:808:41)
    at C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:624:44
    at runSingle (C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:137:13)
    at flush (C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
(node:3880) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3880) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate
the Node.js process with a non-zero exit code.

I tried removing and adding the platform, also removing and adding the node_modules but still get the same error. My Cordova version is 8.0 . anybody knows how to solve this?

like image 718
nimzz Avatar asked Sep 26 '18 08:09

nimzz


People also ask

Could not install from Android as it does not contain a package JSON file?

Could not install from "android" as it does not contain a package. json file. Solution: Simply, I removed the android folder from the root directory, i.e not from the platform directory and then I re-install with the same command.

What is ionic prepare?

ionic prepare copies all files from the www folder into the target platform's www folder. 2. ionic build also does this, but also builds the app's source code so that it can be run on a simulator/emulator or a device.


2 Answers

there was and Android folder created in the root directory (not the platforms directory), after removing this folder the command worked again.

like image 52
nimzz Avatar answered Oct 05 '22 09:10

nimzz


Remove the Android folder from the project directory

like image 31
Neemrode Avatar answered Oct 05 '22 08:10

Neemrode