angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ERROR in Cannot determine the module for class when I try to upgrade from beta24 to beta31

Open rainstormza opened this issue 9 years ago • 8 comments

OS?

El Capitan

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

                         _                           _  _

__ _ _ __ __ _ _ _ | | __ _ _ __ ___ | |() / || '_ \ / _ || | | || | / ` || '|_ / __|| || | | (| || | | || (| || || || || (| || | |___|| ( | || | _,||| || _, | _,||| _,||| _||||| |_/ @angular/cli: 1.0.0-beta.31 node: 6.9.2 os: darwin x64 @angular/common: 2.4.7 @angular/compiler: 2.4.7 @angular/core: 2.4.7 @angular/forms: 2.4.7 @angular/http: 2.4.7 @angular/platform-browser: 2.4.7 @angular/platform-browser-dynamic: 2.4.7 @angular/router: 3.4.7 @angular/cli: 1.0.0-beta.31 @angular/compiler-cli: 2.4.7

Repro steps.

npm uninstall -g angular-cli @angular/cli // from 1.0.0.beta-24 npm cache clean npm install -g @angular/cli@latest npm install -g @angular/compiler@^2.3.1 @angular/compiler-cli@^2.3.1 @angular/core@^2.3.1 @angular/tsc-wrapped@^0.5.0 @ngtools/webpack npm install -g typescript@^2.0.2 zone.js@^0.7.2 npm install -g rxjs

ng serve // work fine ng build // work fine ng build --prod // broken

The log given by the failure.

ERROR in Cannot determine the module for class ShippingAddComponent in /Users/ARM/Desktop/kibito_web/src/app/shipping/shipping-add/shipping-add.component.ts! Cannot determine the module for class ShippingEditComponent in /Users/ARM/Desktop/kibito_web/src/app/shipping/shipping-edit/shipping-edit.component.ts! Cannot determine the module for class ShippingListComponent in /Users/ARM/Desktop/kibito_web/src/app/shipping/shipping-list/shipping-list.component.ts! Cannot determine the module for class ShippingComponent in /Users/ARM/Desktop/kibito_web/src/app/shipping/shipping.component.ts!

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/ARM/Desktop/kibito_web/src' @ ./src/main.ts 5:0-74 @ multi ./src/main.ts

Mention any other details that might be useful.

I try to upgrade angular-cli from beta24 to beta31 everything work fine until I use "ng build --prod" then error appear

"dependencies": { "@angular/common": "^2.3.1", "@angular/compiler": "^2.3.1", "@angular/core": "^2.3.1", "@angular/forms": "^2.3.1", "@angular/http": "^2.3.1", "@angular/platform-browser": "^2.3.1", "@angular/platform-browser-dynamic": "^2.3.1", "@angular/router": "^3.3.1", "bcryptjs": "^2.4.0", "body-parser": "^1.16.0", "cookie-parser": "~1.4.3", "core-js": "^2.4.1", "cors": "^2.8.1", "encoding-japanese": "^1.0.25", "express": "^4.14.0", "jsonwebtoken": "^7.2.1", "morgan": "^1.7.0", "mssql": "^3.3.0", "multer": "^1.3.0", "mydatepicker": "^1.1.15", "ng2-bootstrap": "^1.3.2", "ng2-file-upload": "^1.2.0", "ngx-uploader": "^2.1.2", "rxjs": "^5.0.1", "ts-helpers": "^1.1.1", "underscore": "^1.8.3", "zone.js": "^0.7.2" }, "devDependencies": { "@angular/cli": "^1.0.0-beta.31", "@angular/compiler-cli": "^2.3.1", "@types/jasmine": "2.5.38", "@types/node": "^6.0.42", "@types/underscore": "^1.7.36", "codelyzer": "~2.0.0-beta.1", "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", "nodemon": "^1.11.0", "protractor": "~4.0.13", "ts-node": "1.2.1", "tslint": "^4.0.2", "typescript": "~2.0.3" }

rainstormza avatar Feb 11 '17 12:02 rainstormza

Are these components in the declarations field of any @NgModule?

Meligy avatar Feb 12 '17 23:02 Meligy

@Meligy yes , they are

now I can fix it because when I move folder shipping to subfolder I duplicate it instead of move it so I just delete folder shipping

error is gone 👍

but I still confuse why I can use ng build and ng serve without error

rainstormza avatar Feb 13 '17 09:02 rainstormza

@rainstormza

I am having this issue also - what did you do to solve it?

johnjameshopley avatar Apr 26 '17 10:04 johnjameshopley

@johnjameshopley

that was my mistake that I duplicate folder.

when you use ng build -prod AOT will compile all file in your project that mean if you have component or folder that you did'n't use it or duplicate those files AOT will compile it anyway. you have to remove those file from your project

rainstormza avatar Apr 26 '17 11:04 rainstormza

@rainstormza .... I had a component that contains some errors. so I decided to make a new one ... but I wrote it with the same name so on production .... I have some problems with one of them so I decided to remove the wrong one and let the working component as it is in the project ... but still have the same error. it can not determine the module class of the component ... any help ??

bisho012 avatar Oct 15 '17 18:10 bisho012

@bisho012

Try importing all the angular dependencies first in app.module.ts and then import the components.

` ---------------- First import dependency modules ----------------------- import { BrowserModule } from '@angular/platform-browser'; import { CommonModule } from "@angular/common"; import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { HttpModule } from '@angular/http'; import { ReactiveFormsModule } from '@angular/forms'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

-------------Then Import service modules ------------------------

import { ApplyFormPostService } from './Services/apply-form-post.service'; import { NavBarColorService } from './Services/nav-bar-color.service';

----------------------- Finally import component modules ------------------------

import { AppComponent } from './app.component'; import { HeaderComponent } from './components/header/header.component'; import { CareerComponent } from './components/career/career.component'; import { HomeComponent } from './Components/home/home.component';`

Somehow this solved the AOT compilation error throwing Cannot determine the module for class --- in production mode

KarthikSamyak avatar Nov 30 '17 10:11 KarthikSamyak

Check file name, like here "Email.component" to "email.component" import { EmailComponent } from './Email.component'; TO import { EmailComponent } from './email.component'; Done!

thusithawijethunga avatar Dec 27 '18 04:12 thusithawijethunga

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.