Ionic serve error:no index.html in www folder

created a ionic2 project using sidemenu template but when run ionic serve inside project folder:
Error: ENOENT: no such file or directory, open '/root/Documents/mobile/ionic2/project5/www/index.html’
In github sidemenu project I didn’t find index.html under ww and also there is no build folder inside www.
Even I add platform android, no build folder generated and ionic serve not working

Its working fine in the older projects created earlier, so it may be problem with the latest update?

ionic -v
2.1.1
cordova -v
6.3.1
npm -v
3.10.3
node -v
v6.6.0

This is my directory structure (seems fine to me)
config.xml node_modules plugins tsconfig.json
hooks package.json resources tslint.json
ionic.config.json platforms src www

This is my pacjage.json
{
“name”: “ionic-hello-world”,
“author”: “Ionic Framework”,
“homepage”: “http://ionicframework.com/”,
“private”: true,
“scripts”: {
“ionic:build”: “ionic-app-scripts build”,
“ionic:serve”: “ionic-app-scripts serve”
},
“dependencies”: {
"@angular/common": “2.1.1”,
"@angular/compiler": “2.1.1”,
"@angular/compiler-cli": “2.1.1”,
"@angular/core": “2.1.1”,
"@angular/forms": “2.1.1”,
"@angular/http": “2.1.1”,
"@angular/platform-browser": “2.1.1”,
"@angular/platform-browser-dynamic": “2.1.1”,
"@angular/platform-server": “2.1.1”,
"@ionic/storage": “1.1.6”,
“ionic-angular”: “2.0.0-rc.3”,
“ionic-native”: “2.2.3”,
“ionicons”: “3.0.0”,
“rxjs”: “5.0.0-beta.12”,
“zone.js”: “0.6.26”
},
“devDependencies”: {
"@ionic/app-scripts": “0.0.45”,
“typescript”: “2.0.6”
},
“description”: “project5: An Ionic project”,
“cordovaPlugins”: [
“cordova-plugin-device”,
“cordova-plugin-console”,
“cordova-plugin-whitelist”,
“cordova-plugin-splashscreen”,
“cordova-plugin-statusbar”,
“ionic-plugin-keyboard”
],
“cordovaPlatforms”: []
}
I am using linux (CentOs7)

Normally the index.html is in your src/ folder and then is copied to your www/ folder during the build process.
Do you have an index.html in your src/ folder ?

yes…index.html is in src/

Hi!
I have the same problem
Did you found a solution?

solved!

I have reinstalled ionic
npm install ionic

And now it work fine

Ok so it’s probably in yours scripts from package.json.
But they seems alright. Did @Adalberth solve your solution ?

yes…its working now…
But just wondering why I have to do that…
Thanks @Adalberth

I think you have updated app-script or something like this in package.json
or just changed the scripts array in the same file.
But after you have to perform an npm install to update this node
dependencies.
However node saw you already have app-script (but not the good version) so
node doesn’t reinstall app-script.

This happend because ionic is still in beta. When you update your
depndencies, ionic or whatever in package.json, delete your node_modules
folder and then run npm install.

:

I did this an still is not working

can you please paste your ionic info here?

---------------------app.components.ts-------------------------------------
import { Component, ViewChild } from ‘@angular/core’;
import { Nav, Platform } from ‘ionic-angular’;
import { StatusBar, Splashscreen } from ‘ionic-native’;
import { Page1 } from ‘…/pages/page1/page1’;
import { Page2 } from ‘…/pages/page2/page2’;
@Component({
templateUrl: ‘app.html’
})
export class MyApp {
@ViewChild(Nav) nav: Nav;

  rootPage: any = Page1;

  pages: Array<{title: string, component: any}>;

  constructor(public platform: Platform) {
    this.initializeApp();

    // used for an example of ngFor and navigation
    this.pages = [
      { title: 'Page One', component: Page1 },
      { title: 'Page Two', component: Page2 }
    ];

  }

  initializeApp() {
    this.platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      Splashscreen.hide();
    });
  }

  openPage(page) {
    // Reset the content nav to have just this page
    // we wouldn't want the back button to show in this scenario
    this.nav.setRoot(page.component);
  }
}

------------------------- package.json
{
“name”: “ionic-hello-world”,
“author”: “Ionic Framework”,
“homepage”: “http://ionicframework.com/”,
“private”: true,
“scripts”: {
“ionic:build”: “ionic-app-scripts build”,
“ionic:serve”: “ionic-app-scripts serve”
},
“dependencies”: {
"@angular/common": “2.1.1”,
"@angular/compiler": “2.1.1”,
"@angular/compiler-cli": “2.1.1”,
"@angular/core": “2.1.1”,
"@angular/forms": “2.1.1”,
"@angular/http": “2.1.1”,
"@angular/platform-browser": “2.1.1”,
"@angular/platform-browser-dynamic": “2.1.1”,
"@angular/platform-server": “2.1.1”,
"@ionic/storage": “1.1.6”,
“ionic-angular”: “2.0.0-rc.3”,
“ionic-native”: “2.2.3”,
“ionicons”: “3.0.0”,
“rxjs”: “5.0.0-beta.12”,
“zone.js”: “0.6.26”
},
“devDependencies”: {
"@ionic/app-scripts": “0.0.45”,
“typescript”: “2.0.6”
},
“description”: “PowerLaws”,
“cordovaPlugins”: [
“cordova-plugin-device”,
“cordova-plugin-console”,
“cordova-plugin-whitelist”,
“cordova-plugin-splashscreen”,
“cordova-plugin-statusbar”,
“ionic-plugin-keyboard”
],
“cordovaPlatforms”: []
}

Caught exception:
TypeError: undefined is not a function
at Socket. (C:\Users\me\AppData\Roaming\npm\node_modules\ionic\lib\utils\npmScripts.js:39:49)
at Socket.emit (events.js:129:20)
at readableAddChunk (_stream_readable.js:163:16)
at Socket.Readable.push (_stream_readable.js:126:10)
at Pipe.onread (net.js:538:20)

Hi,
sorry for the delayed reply.
it seems you have updated to rc3
disable antivirus if you have any then open cmd in administrator mode and run npm install -g ionic cordova
this will solve the problem

1 Like

global install with -g solved my problem. thanks.

Please run

$ npm run build
This command will create www folder in your project directory
and then

$ ionic serve

3 Likes

I am facing same issue… tried this solution its not working.

Thank you this solved my problem