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

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.

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.

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

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.

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 "^"

Unable to take production build in angular 5

I'm using angular 2 base template.Later i have updated angular versions to 5 and cli to 1.6.5. I used some external 3rd party packages for my requirement. so while taking production build i'm facing some issues.
can anyone help me to sort out this issue.
so while taking production build this is the error i'm getting.
ERROR in Error during template compile of 'FancyImageUploaderModule'
Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'NgModule'
'NgModule' calls 'ɵmakeDecorator'.
node_modules/rxjs/Subject.d.ts(16,22): error TS2415: Class 'Subject' incorrectly extends base class 'Observable'.
Types of property 'lift' are incompatible.
Type '(operator: Operator) => Observable' is not assignable to type '(operator: Operator) => Observable'.
Type 'Observable' is not assignable to type 'Observable'.
Type 'T' is not assignable to type 'R'.
node_modules/rxjs/observable/dom/WebSocketSubject.d.ts(24,22): error TS2415: Class 'WebSocketSubject' incorrectly extends base class 'AnonymousSubject'.
Types of property 'lift' are incompatible.
Type '(operator: Operator) => WebSocketSubject' is not assignable to type '(operator: Operator) => Observable'.
Type 'WebSocketSubject' is not assignable to type 'Observable'.
Types of property 'operator' are incompatible.
Type 'Operator' is not assignable to type 'Operator'.
Type 'R' is not assignable to type 'T'.
node_modules/#types/lodash/common/object.d.ts(1689,12): error TS2304: Cannot find name 'Exclude'.
node_modules/#types/lodash/common/object.d.ts(1766,12): error TS2304: Cannot find name 'Exclude'.
node_modules/#types/lodash/common/object.d.ts(1842,34): error TS2304: Cannot find name 'Exclude'.
This is my package.json file.
{
"name": "CoreUI",
"version": "1.0.0-alpha.4",
"description": "Open Source Bootstrap Admin Template",
"author": "",
"url": "http://coreui.io",
"copyright": "Copyright 2017 creativeLabs Łukasz Holeczek",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^5.2.2",
"#angular/common": "^5.2.2",
"#angular/compiler": "^5.2.2",
"#angular/core": "^5.2.2",
"#angular/forms": "^5.2.2",
"#angular/http": "^5.2.2",
"#angular/platform-browser": "^5.2.2",
"#angular/platform-browser-dynamic": "^5.2.2",
"#angular/platform-server": "^5.2.2",
"#angular/router": "^5.2.2",
"#angular/upgrade": "2.4.9",
"angular-split": "^1.0.0-rc.3",
"angular2-fontawesome": "^0.9.3",
"angular2-image-upload": "^1.0.0-rc.0",
"angular2-multiselect-dropdown": "^2.2.1",
"angular2-notifications": "^1.0.2",
"angular2-ui-switch": "^1.2.0",
"chart.js": "^2.5.0",
"chart.piecelabel.js": "^0.10.0",
"core-js": "2.4.1",
"e-ngx-fileupload": "^1.2.0",
"font-awesome": "^4.7.0",
"lodash": "^4.17.11",
"moment": "2.17.1",
"mydatepicker": "^2.6.1",
"mydaterangepicker": "^4.2.1",
"ng2-bootstrap": "^1.4.0",
"ng2-charts": "^1.5.0",
"ng2-ckeditor": "^1.2.0",
"ng2-drag-drop": "^3.0.2",
"ng2-dragula": "^1.5.0",
"ng2-fancy-image-uploader": "^2.0.1",
"ng2-split": "^0.1.6",
"ng2-split-pane": "^1.4.0",
"ngx-bootstrap": "^2.0.3",
"ngx-chips": "^1.6.7",
"ngx-cookie-service": "^1.0.10",
"ngx-quill": "^3.4.0",
"ngx-quill-editor": "^2.2.2",
"ngx-toggle-switch": "^1.3.9",
"rxjs": "5.2.0",
"ts-helpers": "1.1.2",
"zone.js": "0.7.2"
},
"devDependencies": {
"#angular/cli": "^1.6.5",
"#angular/compiler-cli": "^5.2.2",
"#types/jasmine": "2.5.45",
"#types/lodash": "^4.14.123",
"#types/node": "7.0.8",
"codelyzer": "2.0.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "3.2.0",
"karma": "1.5.0",
"karma-chrome-launcher": "2.0.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "0.3.0",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"protractor": "5.1.1",
"ts-node": "2.1.0",
"tslint": "4.5.1",
"typescript": "^2.6.2"
}
}