-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERROR in AppModule is not an NgModule #4594
Comments
Don't ask me why, but I think this is a yarn issue. Running rm -rf node_modules
npm i
ng serve fixes the problem, but the problem remains if you do EDIT: another thing that worked was reinstalling yarn : https://yarnpkg.com/lang/en/docs/install/#linux-tab |
Thanks @dessalines |
Ok, I reinstalled yarn using my package manager, removed the node_moduls. used yarn to install. conclusion. This problem happens and is reproducible if you use yarn to install your packages. (which is a shame, as yarn is at least 2 times faster in my situation.) reason (an educated guess!): As yarn is more strict on installing, it probably forces a slightly older dependency in the tree somewhere. |
This problem seems to occur with Typescript 2.1.6. If you clean your node modules, change Typescript to |
So, for me, should I install this yarn? I do not use it |
@tHesTx, no, just use npm install instead. For me, the problem occurs when I use yarn instead. It is solved if I use npm. Also, in my case it was just on the first run, after that it worked ok. |
@SanderElias Yes it was just on the first run for |
I don't know what to do anymore, nothing works. DO I have to update something in package.json or angular-cli.json in my project ? Building gives the same error |
@tHesTx For me, i'd to change If you use global version, you can try: |
@djedje72 I've done that, currently is set to "typescript": "2.1.5". Before to do the first angular-cli update which got me to this point it was like this: "typescript": "~2.0.3". Uninstall and reinstall too. I've also updated the "@angular/cli": "1.0.0-beta.24", "angular-cli": "1.0.0-beta.24", from "devDependencies" to 31, in angular-cli.json: "version": "1.0.0-beta.24", -> to 31 as well. |
Ok, I've generated a new app with angular-cli which works, but in package.json it uses this: "typescript": "~2.0.0" - but I have installed 2.1.5 globally. Why is that? |
Your local Typescript version doesn't necessarily have to match your global. CLI generates a package.json with default dependencies it requires, but you can (and should) updated them according to your needs. I actually had an issue trying to run angular-2.4.7 with typescript 2.0.0 but after updating my project's package.json with typescript 2.1.6 the issue was resolved. #goodnessSquad |
… is not an NgModule" http://stackoverflow.com/questions/41431682/appmodule-is-not-an-ngmodule-error-despite-setting-typescript-to-version-2-0 angular/angular-cli#4594 -- ts version 2.1.5, not 2.1.6 Earlier error: angular/angular-cli#3781
This is a disconnect between Angular 4 and 2.4 that happens in some cases. You probably have an Try with the RC.0, we did fix a few of those mismatch. Also, try to clear your |
@hansl I can confirm the problem is now gone. Even with a yarn installed project! |
I had similar issue with yarn. My problem was resolved by deleting the yarn.lock file and re-running the yarn command. |
FYI, a fix for me was to downgrade to typescript "2.0.2" while keeping cli version at "1.0.0-rc.2". |
I am seeing this error when I install using I don't not see this problem if I do Also I have deleted Here is my package.json file. {
"name": "routes",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "^2.4.10",
"@angular/compiler": "^2.4.10",
"@angular/core": "^2.4.10",
"@angular/forms": "^2.4.10",
"@angular/http": "^2.4.10",
"@angular/platform-browser": "^2.4.10",
"@angular/platform-browser-dynamic": "^2.4.10",
"@angular/router": "^3.4.10",
"@types/node": "^6.0.65",
"codelyzer": "^2.0.1",
"core-js": "^2.4.1",
"rxjs": "^5.2.0",
"ts-helpers": "^1.1.2",
"tslint": "^4.5.1",
"zone.js": "^0.7.8"
},
"devDependencies": {
"@angular/cli": "^1.0.0-rc.4",
"@angular/compiler-cli": "^2.4.10",
"@types/jasmine": "^2.5.46",
"@types/node": "^6.0.65",
"codelyzer": "^2.0.1",
"jasmine-core": "^2.5.2",
"jasmine-spec-reporter": "^2.7.0",
"karma": "^1.5.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.1.0",
"karma-remap-istanbul": "^0.2.2",
"protractor": "^4.0.14",
"tachyons": "^4.6.2",
"ts-node": "^1.7.3",
"tslint": "^4.5.1",
"typescript": "^2.2.1"
}
} |
Same thing here. I upgraded easily from beta.28 to rc.0, then rc.1 and rc.2. However, I face the same problem when upgrading to rc.4. I had to revert to rc.2 for my app to build again. Here is my package.json:
|
I also had to revert back to rc2 from rc4 in order to have my ng serve work again. As previously mentioned, works with npm install but not with yarn |
Downgrading typescript to |
In my case, the problem was that |
I tested upgrading to @angular/cli |
{ |
@lilingling3 Make sure you update all your dependencies to the same version. I see:
3 different angular versions! If you are updating your project, make sure you have the same version on all @angular stuff for use. I would recommend the last stable version (currently 4.1.2). |
Before I used angular-cli ,I use angular/cli now. |
I can also produce this error only when using yarn instead of npm install |
@cport1 same for me. |
I have this problem after a |
Still happening for us with npm. Using angular version 4.2.6 and angular material with typescript 2.2.3 (also tried 2.3 and 2.4). |
@sjswoboda Did you find anything to resolve the issue? This is haunting us for the past week and wasting away our time. Using Typescript |
@IsNull -- we've been through so many errors in the past few weeks, so I cannot remember what fixes what. Based on our change logs, the issue appears to be:
We have since upgraded to 4.3.4 and that is working fine for us. We are using TypeScript 2.4.1 and angular/cli is 1.2.1. So far, we haven't seen these errors again (don't worry, once you resolve these, you'll just get different problems). I am sorry I can't be of more help. |
@sjswoboda Thank you for your support. We have startet tackling the issue (or issues) down and make it reproducible #7384.
There are so many layers, configurations and involved tools, and the error messages are not really helping. Im still amazed how complicated this all turned out. 😅 |
@sjswoboda The cause in our case was that we used to export the index.ts files by omiting their name:
However, all the tooling and standards explicitly allow to omit the See #7394 for the bug report. |
@IsNull -- yes absolutely! That's one thing we had to do as well. We explicitly reference the index file as well. Sorry; I had forgotten that we had also done that. |
I had this issue when I upgraded yarn to 1.2.1. If I rollback to 1.0.0, it works. Maybe there is a newer version between 1.0.0 and 1.2.1 that works. I will keep 1.0.0 for the moment |
just ran into this issue upgrading from angular-cli 1.3 to 1.5.5. Removed node_modules , reinstalled with NPM - same. Removed node_modules, reinstalled with yarn - same. Removed node_modules, removed all yarn-related files, reinstalled with npm, and it worked. VERY strange |
I ran into this same issue, and I don't use yarn. Here is the only way it fixed it for me:
|
I ran into the same issue, this fixed it for me, see reference here: #6425 Here are the versions I used to get it running: yarn: 1.1.0, |
I ran into the same issue myself with Yarn, using this package.lock =>
Which produced the same error as outlined above. In my case the problem was the installed Typescript version that seems to not be compatible with the @angular/cli version After upgrading to Typescript 2.3.4, I got it working fine, and could use AOT compiler with yarn |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
OS?
Versions.
ng --version
@angular/cli: 1.0.0-beta.31
node: 7.2.0
os: win32 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
@ngtools/webpack: 1.2.9
$ npm list -g --depth=0
C:\Users\Macpro\AppData\Roaming\npm
+-- @angular/[email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]
Repro steps.
I've tried to update the angular-cli with these steps: https://github.com/angular/angular-cli#updating-angular-cli
I've done global update and local project as well, all good until I try to serve the app - it gives me the below error
The log given by the failure.
$ ng serve
I also got this "minimatch" errror every time I try to update or install somtehing:
npm update -g
But as you can see above I have "[email protected]" - anyway this is not the problem here
Mention any other details that might be useful.
I've tried to update the typescript like I've seen on the web but with no success. I also
Thank you for your time!
The text was updated successfully, but these errors were encountered: