The current directory does not belong to a Cordova project

Upon executing ionic cordova run browser --verbose within the main directory of my Ionic4 project, I encounter the error message "Current working directory is not a Cordova-based project." as shown below.

I've observed that the command generates a "www" folder briefly before removing it seconds later. If I manually re-add the folder while the command is still running, I can prevent the error from occurring. However, the "www" folder remains empty and the webpage being served displays a "no file found" message.

Current working directory is not a Cordova-based project.
CordovaError: Current working directory is not a Cordova-based project.
at Object.cdProjectRoot (C:\nvm\v11.3.0\node_modules\cordova\node_modules\cordova-lib\src\cordova\util.js:170:15)
... (Output continues) ...
[ERROR] An error occurred while running subprocess cordova.

    cordova run browser --verbose exited with exit code 1.

    Re-running this command with the --verbose flag may provide more information.
... (Output continues) ...   

Additional Information:

Ionic:

   ionic (Ionic CLI)             : 4.5.0 (C:\nvm\v11.3.0\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.0.0-beta.15 (C:\Users\Simon Driesen\Projects\questionnaire-app\node_modules\@ionic\angular)
   @angular-devkit/build-angular : 0.7.5 (C:\Users\Simon Driesen\Projects\questionnaire-app\node_modules\@angular-devkit\build-angular)
   @angular-devkit/schematics    : 7.1.0
   @angular/cli                  : 7.1.0
   @ionic/angular-toolkit        : 1.2.0 (C:\Users\Simon Driesen\Projects\questionnaire-app\node_modules\@ionic\angular-toolkit)

Cordova:

   cordova (Cordova CLI) : not installed
   Cordova Platforms     : not available
   Cordova Plugins       : not available

System:

   NodeJS : v11.3.0 (C:\nodejs\node.exe)
   npm    : 6.4.1
   OS     : Windows 10

Answer №1

Before executing the command, have you attempted to generate the www directory?

If so, try incorporating the www folder into your version control system (such as git or svn) to ensure that it is created when checking out the code. This will prevent the build system from attempting to recreate it.

To exclude everything inside the folder in your .gitignore file (if using git), include the following lines:

# excludes everything inside the folder
www/*
# do not exclude .gitkeep file so the folder can be added to the repository
!www/.gitkeep

Answer №2

Have you attempted running a npm install? It's possible that certain Cordova node modules are not included in your project.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Setting the isLogged variable for other components in Angular 2 can be accomplished by using a shared

I am using a principalService to retrieve the current authenticated user from the backend server, and authService.ts includes a local variable 'isLogged:boolean'. Goal: I need to access the value of 'isLogged' from authService in Navba ...

Adjust the size of the mat-expansion indicator to your desired height and width

Trying to modify the width and height of the mat indicator has been a bit challenging. Despite following suggestions from other similar questions, such as adjusting the border width and padding, I am still unable to see the changes reflect in my CSS file ...

Incorporating onPause and onResume functionalities into a YouTube video featured on a page built with Ionic 2

I'm encountering a minor problem with a simple demo Android app built in Ionic 2. Whenever a Youtube video is playing on the Homepage, if the power button is pressed or the phone goes into sleep/lock mode, the Youtube video continues to play. This is ...

Angular and KeyCloack - Automatically redirect to specific route if user's role does not have access permissions

I am currently working on implementing a mechanism to redirect unauthorized roles when attempting to access restricted routes using the keycloack-angular library: npm install keycloak-angular keycloak-js Custom Guard Implementation export class AuthGuar ...

Having trouble getting Laravel and Angular to filter data by categories?

I am currently developing an ecommerce project using Laravel and Angular. I have products and brands associated with these products. In my function to retrieve the products in Laravel, I have used a nullable parameter like this: public function index($bran ...

I am experiencing issues with Angular routing as it keeps redirecting me back to the main base url

Currently, I am attempting to utilize the angular router in order to navigate from one page to another. Within my page, there is a button that, upon clicking, should direct me to a different page. At this moment, my URL reads as: http://localhost:4200/us ...

What is the best way to instruct Angular to exclude certain sections of a template from compilation?

My scenario is quite straightforward: I am looking to create documentation for my library by including code examples along with demo sections. My main query is this: How can I make one part of the code compilable and executable, while leaving the other pa ...

Encountering an error in Cytoscape using Angular and Typescript: TS2305 - Module lacks default export

I am working on an Angular app and trying to integrate Cytoscape. I have installed Cystoscape and Types/cytoscape using npm, but I encountered an error when trying to import it into my project. To troubleshoot, I started a new test project before implement ...

When the local server and SPA are running on different ports, utilizing an authentication cookie can help bridge the

I currently have a nest.js webserver running on localhost:3000, with an angular frontend served to localhost:4200 (using the dev server). These ports are set as defaults. My authentication process involves sending an access-token in a cookie to the front ...

Troubleshooting a Missing Angular (8) Pipe Error in Your Ionic 4 Application

Despite seeing similar questions posted here, none have provided a solution to my issue. I believe I am implementing it correctly, but clearly something is not right. In the app I'm developing with Ionic 4, I need to add a key to a URL in a gallery. ...

Converting a string to the Date class type in Angular 4: A comprehensive guide

Within my .ts file, I have a string that looks like this: const date = "5/03/2018"; I am looking to convert it into the default date format returned by Angular's Date class: Tue Apr 03 2018 20:20:12 GMT+0530 (India Standard Time) I attempted to do ...

Guide on detecting the Android hardware back button in an Ionic app

I have been attempting to listen for the Android hardware back button, however, I am not seeing any effect. Here is my main code: .run(['$ionicPlatform','$ionicHistory',function($ionicPlatform,$ionicHistory) { $ionicPlatform.read ...

Guide to sending a HTTP POST request with parameters in typescript

I need assistance sending a POST request using parameters in the following format: http://127.0.0.1:9000/api?command={"command":"value","params":{"key":"value","key":"value","key":"value","key":value,}} I attempted to do this but encountered an issue: l ...

What is the reason behind the input value becoming empty after a reset?

Currently, I am working with an input element reference: @ViewChild("inputSearch", { static: false }) This is how the template looks like: <input tabindex="0" type="text" (keydown)="keydownInputSearch($event)" #inputSearch autocomplete="off" ...

Switch things up in the mat-tree angular

Is there a way to change the orientation of a mat-tree-node to "RTL" and adjust the padding to be on the right side? <mat-tree [dataSource]="dataSource" [treeControl]="treeControl"> <mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggl ...

Conceal the Button when the TextBox does not contain valid input

I'm trying to create a textbox with an email pattern that hides a span (click) if the pattern is invalid. I have the following code snippet in place, but it doesn't seem to work as expected: <input type="text" placeholder="Signup for Mailin ...

Issue with Angular's BeforeLoginService causing route authorization to fail

Implementing Route Authorization in Angular-12, I have the following service: BeforeloginService: import { Injectable } from '@angular/core'; import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; i ...

The panning functionality on Android devices within the Firefox browser is currently experiencing issues with both panstart and pan

Currently, I am collaborating on an Angular7 project and utilizing hammerjs version 2.0.1. One of the tasks at hand is to allow panning functionality on a map for mobile devices. After testing on various android devices, I noticed that it performs well on ...

Bringing Angular ECharts into a Stackblitz 15.1 setup: A How-To Guide

Recently, Stackblitz made a change to use a standalone configuration for Angular Projects. However, when trying to initialize the module for Angular ECharts (ngx-echarts), an error occurred: Error in src/main.ts (18:5) Type 'ModuleWithProviders<Ngx ...

Transferring Information Between Components

After logging into my login component, I want to pass data to my navbar component but unfortunately, my navbar content does not update. The navbar component is located in the app-module while the login component is in a separate module. I attempted to us ...