angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.97k forks source link

ERROR in AppModule is not an NgModule #5135

Closed gkucmierz closed 7 years ago

gkucmierz commented 7 years ago

OS?

OSX El Capitan

Versions.

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.0.0-rc.0
node: 6.9.1
os: darwin x64
@angular/common: 4.0.0-rc.1
@angular/compiler: 4.0.0-rc.1
@angular/core: 4.0.0-rc.1
@angular/forms: 4.0.0-rc.1
@angular/http: 4.0.0-rc.1
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 4.0.0-rc.1
@angular/platform-browser-dynamic: 4.0.0-rc.1
@angular/router: 4.0.0-rc.1
@angular/cli: 1.0.0-rc.0
@angular/compiler-cli: 4.0.0-rc.1

Repro steps.

ng serve

The log given by the failure.

ERROR in AppModule is not an NgModule

ERROR in multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
Module not found: Error: Can't resolve '@ngtools/webpack' in '/Users/gkucmierz/learn/coin-tools'
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

ERROR in multi ./src/polyfills.ts
Module not found: Error: Can't resolve '@ngtools/webpack' in '/Users/gkucmierz/learn/coin-tools'
 @ multi ./src/polyfills.ts
webpack: Failed to compile.

Mention any other details that might be useful.

After solved issue with typescript #5131 I have another issue after upgrade ng cli to 1.0.0-rc.0

RicardoVaranda commented 7 years ago

Hey @gkucmierz ,

Can you give me the repro steps to get this issue, I'm not really sure if you are getting this after a new generated project or after upgrading an existing one, the more info the better so that we can reproduce this ourselves to narrow down the issue, Thank you :)

gkucmierz commented 7 years ago

@RicardoVaranda sure It is project generated with: 1.0.0-beta.28.3 https://github.com/gkucmierz/coin-tools/blob/master/package.json#L27

RicardoVaranda commented 7 years ago

It seems you still have an old instance of the cli installed in your local project:

https://github.com/gkucmierz/coin-tools/blob/master/package.json#L27

Can you delete this using: npm uninstall --save angular-cli

Here is an updated package json for your project:

{
  "name": "coin-tools",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve --host 0.0.0.0",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular-redux/store": "^6.0.1",
    "@angular/common": "^2.4.0",
    "@angular/compiler": "^2.4.0",
    "@angular/core": "^2.4.0",
    "@angular/forms": "^2.4.0",
    "@angular/http": "^2.4.0",
    "@angular/platform-browser": "^2.4.0",
    "@angular/platform-browser-dynamic": "^2.4.0",
    "@angular/router": "^3.4.0",
    "@angular/material": "^2.0.0-beta.2",
    "@ngrx/core": "^1.2.0",
    "@ngrx/store": "^2.2.1",
    "base64-js": "^1.2.0",
    "hammerjs": "^2.0.8",
    "jsqr": "^0.2.1",
    "ng2-slim-loading-bar": "^2.4.0",
    "ngrx-store-logger": "^0.1.7",
    "ts-helpers": "^1.1.1",
    "core-js": "^2.4.1",
    "rxjs": "^5.1.0",
    "zone.js": "^0.7.6"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0-rc.0",
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.4.2",
    "typescript": "~2.0.0"
  }
}

I've updated all the dependencies to cli rc0 :)

The only issue I have now in ng serve is missing ngrx-store-freeze module which I'm guessing you didn't commit to github.

gkucmierz commented 7 years ago

Nope, I had indeed and it was showing me this warning:

The package "angular-cli" has been renamed to "@angular/cli". The old package will be deprecated soon.

Please take the following steps to avoid issues:
"npm uninstall --save angular-cli" 

After I uninstalled it, warning disappeared, but there is still that error.

RicardoVaranda commented 7 years ago

Do the following steps within your project and report back:

rm -rf node_modules
npm install
ng serve

Also if possible, use the package.json I posted above as all the dependencies match the new rc.0

gkucmierz commented 7 years ago

ls node_modules/ | grep angular-cli returns nothing

gkucmierz commented 7 years ago
MacBook-Pro-gkucmierz:coin-tools gkucmierz$ ls -al node_modules/ | grep angular
drwxr-xr-x   16 gkucmierz  staff    544  1 mar 12:02 @angular
drwxr-xr-x    3 gkucmierz  staff    102 19 lut 17:33 @angular-redux
RicardoVaranda commented 7 years ago

It seems your are missing a dependency of ngrx-store-freeze also:

npm i --save-dev ngrx-store-freeze

I was able to do a git pull and ng serve with no errors after installing that dependency:

image

gkucmierz commented 7 years ago

After reinstalling all packages, all systems are working, thx!

jasonspick commented 7 years ago

I cleared node_modules and reinstalled. no luck. Using Angular 4, angular cli 1.0.0 and typescript 2.2.2

laurentsd commented 7 years ago

I cleared node_modules and reinstalled. no luck. Using Angular 4, angular cli 1.0.0 and typescript 2.2.2

same here

Nasruddin commented 6 years ago

I solved the issue by updating Typescript version to "~2.3.0"

angular-automatic-lock-bot[bot] commented 5 years ago

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.