Ionic2 rc0 (ionic cli 2.1): out of the box tutorial template ionic serve fails

Hello,

I installed the latest version of ionic cli, like this:

npm remove -g ionic
npm install -g ionic

when i type ionic i see the version of ionic cli:

ionic
  _             _          
 (_)           (_)         
  _  ___  _ __  _  ___     
 | |/ _ \| '_ \| |/ __| 
 | | (_) | | | | | (__     
 |_|\___/|_| |_|_|\___|  CLI v2.1.0

Then i install a new project like this:

ionic start mobile_app_poc_ionic2 tutorial --v2

then i run

ionic serve

and i get error:

Running 'serve:before' npm script before serve
> mobile_app_poc_ionic2@ watch /home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0
> ionic-app-scripts watch
[11:23:32]  ionic-app-scripts 0.0.23
[11:23:32]  watch started ...
[11:23:32]  build dev started ...
[11:23:32]  clean started ...
[11:23:32]  clean finished in 4 ms
[11:23:32]  copy started ...
[11:23:32]  typescript compiler started ...
[11:23:32]  lint started ...
[11:23:32]  

[11:23:32]  copy finished in 57 ms
[11:23:35]  src/app/app.component.ts(1,38): error TS2307: Cannot find module '@angular/core'.
[11:23:35]  src/app/app.module.ts(1,26): error TS2307: Cannot find module '@angular/core'.
[11:23:35]  src/app/main.dev.ts(1,40): error TS2307: Cannot find module '@angular/platform-browser-dynamic'.
[11:23:35]  src/pages/hello-ionic/hello-ionic.ts(1,27): error TS2307: Cannot find module '@angular/core'.
[11:23:35]  src/pages/item-details/item-details.ts(1,27): error TS2307: Cannot find module '@angular/core'.
src/pages/list/list.ts(1,27): error TS2307: Cannot find module '@angular/core'.
[11:23:35]  typescript compiler ready in 3.29 s
[11:23:35]  bundle dev started ...
[11:23:35]  Error: Could not resolve '@angular/platform-browser-dynamic' from /home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/.tmp/app/main.dev.js
    at Error (native)
    at /home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.cjs.js:78:21
    at /home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/browser-resolve/index.js:265:24
    at /home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:46:14
    at process (/home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:173:43)
    at ondir (/home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:188:17)
    at load (/home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:69:43)
    at onex (/home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:92:31)
    at /home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:82:15)

[11:23:35]  sass started ...
[11:23:35]  sass failed:  Cannot generate Sass files without first bundling JavaScript files in order to know all used modules. Please build JS files first.

[11:23:35]  build dev failed:  Build failed

[11:23:35]  

[11:23:35]  watch ready in 3.60 s
Running live reload server: http://10.0.0.129:35729
Watching: www/**/*, !www/lib/**/*
āˆš Running dev server:  http://10.0.0.129:8100

You need to update npm package also

npm install -g npm

use ionic start ... --verbose to get more information
I just update recently also and got the same problem because of this

1 Like

maybe you should update ionic-cli.

so You must check npm outdated.

npm outdated -g

and update ionic latest version.

Strangeā€¦ for me it still does not work:

i updated npm to latest version

npm --version
3.10.8

i again removed ionic cli and added it again

npm remove -g ionic
npm install -g ionic

then i install the tutorial project again:

ionic start mobile_app_poc_ionic2 tutorial --v2

and i run

ionic serve

and i get errors:

Running 'serve:before' npm script before serve
> mobile_app_poc_ionic2@ watch /home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0
> ionic-app-scripts watch
[12:13:38]  ionic-app-scripts 0.0.23
[12:13:38]  watch started ...
[12:13:38]  build dev started ...
[12:13:38]  clean started ...
[12:13:38]  clean finished in 10 ms
[12:13:38]  copy started ...
[12:13:38]  typescript compiler started ...
[12:13:39]  lint started ...
[12:13:39]  

[12:13:39]  copy finished in 81 ms
[12:13:42]  src/app/app.component.ts(1,38): error TS2307: Cannot find module '@angular/core'.
[12:13:42]  src/app/app.module.ts(1,26): error TS2307: Cannot find module '@angular/core'.
[12:13:42]  src/app/main.dev.ts(1,40): error TS2307: Cannot find module '@angular/platform-browser-dynamic'.
[12:13:42]  src/pages/hello-ionic/hello-ionic.ts(1,27): error TS2307: Cannot find module '@angular/core'.
src/pages/item-details/item-details.ts(1,27): error TS2307: Cannot find module '@angular/core'.
[12:13:42]  src/pages/list/list.ts(1,27): error TS2307: Cannot find module '@angular/core'.
[12:13:42]  typescript compiler ready in 3.97 s
[12:13:42]  bundle dev started ...
[12:13:43]  Error: Could not resolve '@angular/platform-browser-dynamic' from /home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/.tmp/app/main.dev.js
    at Error (native)
    at /home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.cjs.js:78:21
    at /home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/browser-resolve/index.js:265:24
    at /home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:46:14
    at process (/home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:173:43)
    at ondir (/home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:188:17)
    at load (/home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:69:43)
    at onex (/home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:92:31)
    at /home/andrei/Projects/var/Mobile_POC_Ionic/ionic2/mobile_app_poc_ionic2_rc0_angular2.0/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:82:15)

[12:13:43]  sass started ...
[12:13:43]  sass failed:  Cannot generate Sass files without first bundling JavaScript files in order to know all used modules. Please build JS files first.

[12:13:43]  build dev failed:  Build failed

[12:13:43]  

[12:13:43]  watch ready in 4.31 s
Running live reload server: http://10.0.0.129:35729
Watching: www/**/*, !www/lib/**/*, !www/**/*.map
āˆš Running dev server:  http://10.0.0.129:8100
Ionic server commands, enter:
  restart or r to restart the client app from the root
  goto or g and a url to have the app navigate to the given url
  consolelogs or c to enable/disable console log output
  serverlogs or s to enable/disable server log output
  quit or q to shutdown the server and exit

ionic $ 



can you try --verbose on ionic start command?

ionic start mobile_app_poc_ionic2 tutorial --v2 --verbose

And see any warning or error message that might appear

I had this issue too, you have to install node js 6.7

i have node 4.6 (LTS);
i will try to upgrade

1 Like

Thank you !
I installed node 6.7 and ionic serve worked.

1 Like

Hi
9 times out of 10 I have ā€œbuild dev failedā€ when I run serve.
Did I missed something ?

Cordova CLI: 6.2.0
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
Node Version: v6.7.0

maybe you need also npm 3

I already have npm 3.9.3, updated to 3.10.8 but same thing

Node 5 is dead. Either use 4 of 6. Iā€™m on 4 and its working fine

Under Windows 7, itā€™s working much better with Node 4.6 !

Mmmmm I still have a lot of ā€œbuild dev failedā€ā€¦ Realy donā€™t know how to get a stable build process with Serve and Run android

I had the same issue. Ctrl + C before you run ā€œionic serveā€, will help. I donā€™t know why, but it seems to work for me.

After this error, run npm install , if you get some error related to git , than follow below steps, it resolved for me:
Go to https://git-for-windows.github.io/ and install git
than open git cmd
run below command:
git config --global url.ā€œhttps://ā€.insteadOf git://

This resolved issues for me

I had a similar problem. According to https://github.com/driftyco/ionic/blob/master/CHANGELOG.md#copying-your-project-to-a-new-project you should not be on an ionic beta version. I tried uninstalling and reinstalling ionic cli globally and it still tells me I have version 2.0.0-beta.23.
My current workaround is to run npm run build. Otherwise it seems that ionic serve expects the www contents to already be built. I have npm version 3.10.3 node version 6.7.0. I hope this helps.

OK I found that I have to manualy remouve the .tmp folder content to avoid the build failed ā€¦ Donā€™t know why it is not properly done when I run Serve or Run.

Yes! Me too! Magic in Action!