Angular 6: error TS2315: Type 'ModuleWithProviders' is not generic - core and forms versions is same - angular6

My routing was not working correctly, I have separate paths for two components but still they were shown one below the other in second component's path, reason: below error in my console,
Inspite of trying the solution given here ANGULAR 6: error TS2315: Type 'ModuleWithProviders' is not generic,
I am still getting same error, and now it is not even compiling.
I am searching solution since past few hours but no luck.
ERROR in node_modules/#angular/platform-browser/src/browser.d.ts(45,9): error TS2315: Type >'ModuleWithProviders' is not generic.
node_modules/#angular/router/src/router_module.d.ts(101,60): error TS2315: Type >'ModuleWithProviders' is not generic.
node_modules/#angular/router/src/router_module.d.ts(105,38): error TS2315: Type >'ModuleWithProviders' is not generic.
Below is my package.json,
{
"name": "cakewale",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^6.0.0",
"#angular/cdk": "^6.0.0",
"#angular/common": "^6.0.3",
"#angular/compiler": "^6.0.3",
"#angular/core": "6.0.3",
"#angular/forms": "6.0.3",
"#angular/http": "^6.0.3",
"#angular/platform-browser": "^6.0.3",
"#angular/platform-browser-dynamic": "^6.0.3",
"#angular/router": "^6.0.3",
"animate.css": "^3.7.2",
"core-js": "^2.5.4",
"rxjs": "6.0.0",
"wowjs": "^1.1.3",
"zone.js": "^0.8.26"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.6.8",
"#angular/cli": "~6.0.8",
"#angular/compiler-cli": "^6.0.3",
"#angular/language-service": "^6.0.3",
"#types/jasmine": "~2.8.6",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"shallow-render": "^7.2.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "~2.7.2"
}
}
I was thinking to change the versions to 6.1.2, but I am scared it might result in altogether new errors, would anyone recommend that?
I am not able to figure out what am I missing, please help.
Thanks for any help.

I was trying to use some new libraries and guess accidentally mismatched the versions of #angular/core #angular/router #angular/platform-browser
I removed the ^ sign from versions of all the three above to make sure their versions are exactly same, it worked.

Related

Build Issue With Angular Project while updating Angular 7 to 13

I wanted to upgrade the Angular version in my project from 7 to 13, but I am facing some issues. Below you can see my package in Json format:
{
"name": "comresi-angular",
"version": "0.0.0",
"scripts": {
"start": "ng serve",
"start:local": "ng serve --base-href=/",
"build:prod": "ng build --configuration production",
"build:dev": "ng build ----configuration dev",
"build:local": "npm run build:dev && npm run copy_tomcat",
"copy_tomcat": "xcopy \"../webapp/resources\\*\" \"%CATALINA_HOME%\\webapps\\erlcr\\resources\" /s /i /y > nul"
},
"private": true,
"dependencies": {
"#angular/animations": "~13.1.0",
"#angular/cdk": "~13.1.0",
"#angular/common": "~13.1.0",
"#angular/compiler": "~13.1.0",
"#angular/core": "~13.1.0",
"#angular/forms": "~13.1.0",
"#angular/http": "^7.0.0",
"#angular/material": "~13.1.0",
"#angular/platform-browser": "~13.1.0",
"#angular/platform-browser-dynamic": "~13.1.0",
"#angular/service-worker": "~13.1.0",
"#angular/router": "~13.1.0",
"#ngx-translate/core": "11.0.1",
"#ngx-translate/http-loader": "4.0.0",
"#types/bingmaps": "0.0.1",
"#types/jquery": "^3.3.22",
"#types/npm": "^2.0.29",
"#types/slickgrid": "^2.1.26",
"ag-grid-angular": "^19.0.0",
"ag-grid-community": "^19.0.0",
"angular-maps": "^6.0.1",
"angular-slickgrid": "^2.1.8",
"bingmaps": "^2.0.3",
"bootstrap": "^4.1.3",
"core-js": "^2.5.4",
"dhtmlx-gantt": "file:gantt_7.1.8_evaluation",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"jqwidgets-scripts": "^6.1.0",
"moment": "^2.19.1",
"rxjs": "~7.4.0",
"rxjs-compat": "^7.4.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#angular-devkit/build-angular": "13.1.2",
"#angular/cli": "~13.1.0",
"#angular/compiler-cli": "~13.1.0",
"#angular/language-service": "~13.1.0",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "~4.3.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~4.4.3",
"rxjs": "~7.4.0"
}
}
but I am getting the following error while running npm install:
While resolving: comresi-angular#0.0.0
Found: #angular-devkit/build-angular#0.10.7
node_modules/#angular-devkit/build-angular
dev #angular-devkit/build-angular#"13.1.2" from the root project
Could not resolve dependency:
dev #angular-devkit/build-angular#"13.1.2" from the root project
Conflicting peer dependency: #angular/core#13.1.1
node_modules/#angular/core
peer #angular/core#"13.1.1" from #angular/service-worker#13.1.1
node_modules/#angular/service-worker
#angular/service-worker#"~13.1.0" from the root project
peerOptional #angular/service-worker#"^13.0.0 || ^13.1.0-next" from #angular-devkit/build-angular#13.1.2
node_modules/#angular-devkit/build-angular
dev #angular-devkit/build-angular#"13.1.2" from the root project
Could you help me to understand why I am getting that error?
If you use the official angular update website and you put your angular versions From 7.0 To 13.0 you will get the following warning:
so obviously you need to go through all the major versions until v13.0
As per my experience with project. It is better to build a simple product with latest version (or version which you want). and add a component from your existing application gradually.

Is a version incompatibility preventing my Angular CLI animations from working?

I have a project to do. The Angular project was already set up when I started working. However, the animations do not seem to work properly. When I put a mat input placeholder, the placeholder doesn't disappear when I start writing in it. When I put a mat-select, the select doesn't drop down.
There's my package.json:
{
"name": "projetwifi-dashboard",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"serve": "ng serve --configuration=dev",
"start": "node server.js",
"build": "ng build",
"build:dev": "ng build --prod --configuration=dev",
"build:accept": "ng build --prod --configuration=accept",
"build:prod": "ng build --prod --configuration=production",
"test": "ng test",
"test:ci": "ng test --code-coverage=true --watch=false",
"lint": "ng lint && prettier -l \"**/*.ts\"",
"lint-fix": "ng lint --fix && prettier \"**/*.ts\" --write",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "~10.2.0",
"#angular/cdk": "^12.0.0",
"#angular/common": "~10.2.0",
"#angular/compiler": "^10.2.5",
"#angular/core": "~10.2.0",
"#angular/forms": "~10.2.0",
"#angular/material": "^10.2.7",
"#angular/platform-browser": "~10.2.0",
"#angular/platform-browser-dynamic": "~10.2.0",
"#angular/router": "~10.2.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"express-prom-bundle": "^6.2.0",
"googleapis": "^74.2.0",
"prom-client": "^12.0.0",
"puppeteer": "^5.4.1",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.1002.3",
"#angular/cli": "~10.2.0",
"#angular/compiler-cli": "^10.2.5",
"#types/jasmine": "~3.5.0",
"#types/jasminewd2": "~2.0.3",
"#types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}
}
I have tried many version of the dependencies but nothing seems to resolve the problem. Any ideas? Thanks
welcome to the SO community! In order to answer your question, I'm gonna have to take a guess, since you didn't provide us with a minimum reproducible example.
Usually, in order for angular animations to work, you have to include BrowserAnimationsModule as stated by the documentation.
Here's how I would do that:
import { NgModule } from '#angular/core';
import { BrowserModule } from '#angular/platform-browser';
import { BrowserAnimationsModule } from '#angular/platform-browser/animations';
#NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule
],
declarations: [ ],
bootstrap: [ ]
})
export class AppModule { }
Once you have that, you'll be able to work with Angular animations. Please use the link above to see how it fully works, but essentially, my hunch is that you didn't include this module and hence, your animations don't work. The guide I've given is the official Angular documentation, and it should help you get started.

ERROR in ./node_modules/ng2-smart-table/ng2-smart-table.ngfactory.js

I am getting the below error. when i do "ng build --prod --aot"
ERROR in ./node_modules/ng2-smart-table/ng2-smart-table.ngfactory.js
Module not found: Error: Can't resolve '../#akveo/ng2-completer/ng2-completer.ngfactory' in 'C:\Shruthi\Applications\PULSE\Q2-error\pulse\Pulse-web\node_modules\ng2-smart-table'
everything works fine when i do ng build.
I am getting this error from yesterday everything was working fine in before yesterday.
Is it error because of ng2-completer or something related ng build or angular version.
below is my package.json
{
"name": "pulse-web",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"compodoc": "compodoc",
"generate-docs": "compodoc -p src/tsconfig.app.json",
"serve-docs": "compodoc -s src/tsconfig.app.json"
},
"private": true,
"dependencies": {
"#akveo/ng2-completer": "^9.0.1",
"#amcharts/amcharts4": "^4.9.6",
"#angular/animations": "~7.2.0",
"#angular/cdk": "~7.2.0",
"#angular/common": "~7.2.0",
"#angular/compiler": "~7.2.0",
"#angular/core": "~7.2.0",
"#angular/forms": "~7.2.0",
"#angular/http": "^7.2.16",
"#angular/material": "~7.2.0",
"#angular/platform-browser": "~7.2.0",
"#angular/platform-browser-dynamic": "~7.2.0",
"#angular/router": "~7.2.0",
"#compodoc/compodoc": "^1.1.11",
"#mc-dxp/dxp-styles": "^3.2.1",
"#mc-dxp/dxp-web": "^4.1.1",
"#ng-bootstrap/ng-bootstrap": "^4.1.5",
"#syncfusion/ej2-angular-buttons": "^17.4.49",
"#syncfusion/ej2-angular-lists": "^17.4.47",
"#syncfusion/ej2-angular-navigations": "^17.4.49",
"#types/crypto-js": "^3.1.43",
"acorn": "^6.1.1",
"bootstrap": "^4.4.1",
"core-js": "^2.5.4",
"jquery": "^3.4.1",
"jw-angular-pagination": "^1.1.0",
"moment": "^2.24.0",
"ng2-completer": "^2.0.8",
"ng2-smart-table": "^1.5.0",
"ngx-bootstrap": "^5.3.2",
"ngx-cookie-service": "^2.3.0",
"ngx-select-dropdown": "1.3.0",
"popper.js": "^1.16.1",
"rxjs": "~6.3.3",
"rxjs-compat": "^6.5.4",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.13.0",
"#angular/cli": "~7.3.8",
"#angular/compiler-cli": "~7.2.0",
"#angular/language-service": "~7.2.0",
"#types/node": "~8.9.4",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
}
}
Pleas help me! Not able to figure out the reason
It seems to be a problem with the library itself. See this: https://github.com/akveo/ng2-smart-table/issues/1143. We are also facing the same problem while upgrading our application to Angular 9.
If you are using Ang 9
Upgrade these libraries to these versions
"ng2-completer": "^9.0.1",
"ng2-smart-table": "^1.6.0",
"typescript": "3.8.3" // note explicit ie no "~" or "^"

Angular ng serve is not hosting site on localhost

When I run ng serve on my CLI, I get the following output:
Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/
But when I open http://localhost:4200/ in my browser so there is nothing.
Any advice on how to solve this issue?
Here's my package.json
{
"name": "eastlaw",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^6.1.0",
"#angular/common": "^6.1.0",
"#angular/compiler": "^6.1.0",
"#angular/core": "^6.1.0",
"#angular/forms": "^6.1.0",
"#angular/http": "^6.1.0",
"#angular/platform-browser": "^6.1.0",
"#angular/platform-browser-dynamic": "^6.1.0",
"#angular/router": "^6.1.0",
"core-js": "^2.5.4",
"rxjs": "6.0.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.7.0",
"#angular/cli": "~6.1.5",
"#angular/compiler-cli": "^6.1.0",
"#angular/language-service": "^6.1.0",
"#types/jasmine": "~2.8.6",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "~2.7.2"
}
}
To debug the issue try the following :
ng serve -o
Check the default port mentioned in config file with the key baseURL
check with ng build command (if webpack is getting generated)
ng serve --port 8080 --host 0.0.0.0 --disableHostCheck true
if possible try to upload browser console image
Consider these things :
By opening server via ng serve, it can only be opened on
browsers on that device.
If you want to serve it for the devices on your network you should use ng serve --
host <your_device_ip>
Note: Device IP is the IP Address of the device you are serving from.
First, verify your machine IP Address.
On Windows, type ipconfig in Prompt (copy IPv4). On Mac, type ifconfig |grep inet in Terminal (copy inet).
In my case, this is 192.168.0.10. Next, type the command ng serve --host 192.168.0.10 Ok, your app on air for all devices on the same network.
Now only http://192.168.0.10:4200/ will work, localhost not more.

TypeError: Cannot read property 'length' of undefined (Converting angular to angular 4)

TypeError: Cannot read property 'length' of undefined
Console log
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at createSourceFile (c:\Users\Amina\Desktop\LendingTree\node_modules\typescript\lib\typescript.js:15457:109)
at parseSourceFileWorker (c:\Users\Amina\Desktop\LendingTree\node_modules\typescript\lib\typescript.js:15389:26)
at Object.parseSourceFile (c:\Users\Amina\Desktop\LendingTree\node_modules\typescript\lib\typescript.js:15338:26)
at Object.createSourceFile (c:\Users\Amina\Desktop\LendingTree\node_modules\typescript\lib\typescript.js:15192:29)
at new TypeScriptFileRefactor (c:\Users\Amina\Desktop\LendingTree\node_modules\#ngtools\webpack\src\refactor.js:34:35)
at Object.resolveEntryModuleFromMain (c:\Users\Amina\Desktop\LendingTree\node_modules\#ngtools\webpack\src\entry_resolver.
js:105:20)
at AotPlugin._setupOptions (c:\Users\Amina\Desktop\LendingTree\node_modules\#ngtools\webpack\src\plugin.js:152:50)
at new AotPlugin (c:\Users\Amina\Desktop\LendingTree\node_modules\#ngtools\webpack\src\plugin.js:27:14)
at _createAotPlugin (c:\Users\Amina\Desktop\LendingTree\node_modules\#angular\cli\models\webpack-configs\typescript.js:55:
12)
at Object.exports.getNonAotConfig (c:\Users\Amina\Desktop\LendingTree\node_modules\#angular\cli\models\webpack-configs\typ
escript.js:71:19)
at NgCliWebpackConfig.buildConfig (c:\Users\Amina\Desktop\LendingTree\node_modules\#angular\cli\models\webpack-config.js:2
9:37)
at Class.run (c:\Users\Amina\Desktop\LendingTree\node_modules\#angular\cli\tasks\serve.js:43:98)
at check_port_1.checkPort.then.port (c:\Users\Amina\Desktop\LendingTree\node_modules\#angular\cli\commands\serve.js:114:26
)
at process._tickCallback (internal/process/next_tick.js:109:7)
Package.Json
{
"name": "lending-tree",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#agm/core": "^1.0.0-beta.1",
"#angular/animations": "^4.2.4",
"#angular/common": "^4.2.4",
"#angular/compiler": "^4.2.4",
"#angular/core": "^4.2.4",
"#angular/forms": "^4.2.4",
"#angular/http": "^4.2.4",
"#angular/platform-browser": "^4.2.4",
"#angular/platform-browser-dynamic": "^4.2.4",
"#angular/router": "^4.2.4",
"#types/googlemaps": "^3.29.0",
"core-js": "^2.4.1",
"rxjs": "^5.4.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"#angular/cli": "1.3.1",
"#angular/compiler-cli": "^4.2.4",
"#angular/language-service": "^4.2.4",
"#types/jasmine": "~2.5.53",
"#types/jasminewd2": "~2.0.2",
"#types/node": "~6.0.60",
"codelyzer": "~3.1.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.3.2",
"typescript": "~2.3.3"
}
}
I have created a new project with cli ng new projectName
Replaced app folder with my existing project.
Added template for front view in the root directory of an application.
Updated index.html only added some css and scripts.
Moved main.ts src to app folder, and changed the imports statements.
That are only changes, I have made so far.