ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Build failing

Open tomasbedrich opened this issue 10 years ago • 32 comments

Short description of the problem:

Cannot build a fresh app. There are multiple errors in the build process (see bellow).

Steps to reproduce:

  1. ionic start --v2 myProject
  2. cd myProject
  3. ionic serve

Build log:

...
[00:20:13]  src/app/app.component.ts(1,27): error TS2307: Cannot find module '@angular/core'.
[00:20:13]  src/app/app.module.ts(1,26): error TS2307: Cannot find module '@angular/core'.
[00:20:13]  src/app/main.dev.ts(1,40): error TS2307: Cannot find module '@angular/platform-browser-dynamic'.
[00:20:13]  src/pages/about/about.ts(1,27): error TS2307: Cannot find module '@angular/core'.
[00:20:13]  src/pages/contact/contact.ts(1,27): error TS2307: Cannot find module '@angular/core'.
[00:20:13]  src/pages/home/home.ts(1,27): error TS2307: Cannot find module '@angular/core'.
[00:20:13]  src/pages/tabs/tabs.ts(1,27): error TS2307: Cannot find module '@angular/core'.
[00:20:13]  typescript compiler ready in 4.38 s
[00:20:13]  bundle dev started ...
[00:20:13]  Error: Could not resolve '@angular/platform-browser-dynamic' from /Users/ricoo/ownCloud/work/fxe/myProject/.tmp/app/main.dev.js
    at Error (native)
    at /Users/ricoo/ownCloud/work/fxe/myProject/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.cjs.js:78:21
    at /Users/ricoo/ownCloud/work/fxe/myProject/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/browser-resolve/index.js:265:24
    at /Users/ricoo/ownCloud/work/fxe/myProject/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:46:14
    at process (/Users/ricoo/ownCloud/work/fxe/myProject/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:173:43)
    at ondir (/Users/ricoo/ownCloud/work/fxe/myProject/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:188:17)
    at load (/Users/ricoo/ownCloud/work/fxe/myProject/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:69:43)
    at onex (/Users/ricoo/ownCloud/work/fxe/myProject/node_modules/@ionic/app-scripts/node_modules/rollup-plugin-node-resolve/node_modules/resolve/lib/async.js:92:31)
    at /Users/ricoo/ownCloud/work/fxe/myProject/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)

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

[00:20:13]  build dev failed:  Build failed
...

Which Ionic Version? 2.0.0-rc.0

Run ionic info from terminal/cmd prompt:

Your system information:

Cordova CLI: 6.3.1
Gulp version:  CLI version 3.9.1
Gulp local:  
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.0.0-beta.20
ios-deploy version: 1.8.5 
ios-sim version: 5.0.4 
OS: Mac OS X El Capitan
Node Version: v4.4.7
Xcode version: Xcode 8.0 Build version 8A218a 

tomasbedrich avatar Sep 28 '16 22:09 tomasbedrich

@jgw96 I still have this issue:

Ionic Framework Version: 2.0.0-rc.0 Ionic CLI Version: 2.1.0 Ionic App Lib Version: 2.0.0-beta.20 OS: Mac OS X El Capitan Node Version: v6.7.0 npm: 3.10.3

Started new project after updating to latest version of Ionic (project has new folder structure).

[00:18:40] Error: Could not resolve '@angular/platform-browser-dynamic' from /listApp3/.tmp/app/main.dev.js

Updated npm, node, ... any other ideas?

rept avatar Sep 30 '16 22:09 rept

Not sure if it helps, but I have done npm cache clean before creating a new project.

tomasbedrich avatar Sep 30 '16 23:09 tomasbedrich

@tomasbedrich did npm cache clean and then created new blank project and now it works!

rept avatar Oct 01 '16 07:10 rept

@tomasbedrich Thank you so much! You just helped me out! Wow!

johnofkorea avatar Oct 01 '16 17:10 johnofkorea

install the latest nodejs 6.7 but ionic info shows:

Ionic CLI Version: 2.1.0 Ionic App Lib Version: 2.0.0-beta.20 OS: Windows 8.1 Node Version: v0.12.2 npm 2.7.4.

try to install the latest npm

npm install npm@latest -g dont' seem to work, always getting 2.7.4

now still getting the same "@angular/core" not found error with rc0.

koo9 avatar Oct 02 '16 18:10 koo9

C:\Users\dev>npm install npm -g C:\Users\dev\AppData\Roaming\npm\npm -> C:\Users\dev\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js [email protected] C:\Users\dev\AppData\Roaming\npm\node_modules\npm

C:\Users\dev>npm -version 2.7.4

C:\Users\dev>npm cache clean

C:\Users\dev>npm -v 2.7.4

looks like npm 3.10.8 is installed but the version still shows 2.7.4. that's odd.

koo9 avatar Oct 02 '16 18:10 koo9

after pulling half head of hair, finally narrow down the cause. the issue is npm won't update no matter what I did. npm remove -g npm or npm uninstall -g npm, uninstall nodejs then install the latest, none of them make a difference. finally found this step to manually remove npm from winodws http://stackoverflow.com/questions/20711240/how-to-completely-remove-node-js-from-windows then reinstall the latest nodejs. after that, npm install -g npm update works fine. RC0 compiles fine as well.

koo9 avatar Oct 03 '16 03:10 koo9

I found how to fix this issue (at least for my app, but maybe will be useful for somebody else). I had components, services, interfaces folders inside the app folder. After moving them one level up (to src) and changing imports, build passed successfully.

had same situation, all my custom components were inside ./app folder...

moved them out, inside ./src folder, in the same level with ,/app folder and this fixed build error

BaHXeLiSiHg avatar Oct 03 '16 09:10 BaHXeLiSiHg

Im also getting this error. Installing again node did not help. Anyone have any ideas?

ionic info:

Your system information:

Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Mac OS X El Capitan
Node Version: v6.7.0
Xcode version: Xcode 8.0 Build version 8A218a 

Also tried with node version of 5.10 and npm 3.8. Same error

royipressburger avatar Oct 04 '16 20:10 royipressburger

deleted the broken app updated npm and created a new app and everything is working. Looking forward to take Ionic for a spin. I have an existing jquery mobile app I want to convert.

Martin-Andersen avatar Oct 09 '16 08:10 Martin-Andersen

@e-oz Thank you thank you thank you!!! I had the same problem (same error regarding the /.tmp/app/main.dev.js)
[edit] here is a screenshot of the non working structure. Please note that features, shared, and the app.modules.ts, ... are on the same level. selection_001
tsconfig.tmp.json was like

{
  "compilerOptions": {
    "sourceMap": true,
    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "target": "es5",
    "outDir": "/mnt/nolazybits/<my_project_path>/.tmp"
  },
  "exclude": [
    "node_modules"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  },
  "include": [
    "/mnt/nolazybits/<my_project_path>/src/app/main.dev.ts",
    "/mnt/nolazybits/<my_project_path>/src/**/*.d.ts"
  ]
}

my_project_path being obvisouly the path on my hard drive (cut to make it short)
So yes the generated tsconfig.tmp.json is wrong. The main.dev.js is not in the app folder but at the root in this instance see the following image
selection_003 [/edit]

[edit2] So after updating to the last ionic-app-script it seems fine now. It seems that the build process changed (there is no more .tmp folder)? Can anyone confirm? Anyhow it seems that it is now compiling fine without error :) [/edit2] @here Is there no way to actually have the structure we like, even if it means changing few configs. If so which ones and how please.

nolazybits avatar Oct 11 '16 08:10 nolazybits

Though not entirely related to OP's post, but if it helps someone like me who stumbles across this thread it's worth it:

I had this issue while trying to build with Visual Studio 2015. The solution was opening up command prompt, navigating to the directory of my project and running npm install manually. That worked like a charm.

ranneyd avatar Nov 06 '16 04:11 ranneyd