简体   繁体   English

Angular - TypeError:无法读取 null 的属性“nodeName”

[英]Angular - TypeError: Cannot read property 'nodeName' of null

I have updated a lot of dependencies of my project, it's based on a theme that recently released a new version and I updated my project with this new version.我更新了我的项目的很多依赖项,它基于最近发布新版本的主题,我用这个新版本更新了我的项目。

The problem, is that I'm having many issues after the updates (as I expected), but after fixing all compiler issues I find myself with this error:问题是,更新后我遇到了很多问题(正如我所料),但是在修复了所有编译器问题后,我发现自己遇到了这个错误:

Error:错误:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'nodeName' of null TypeError: Cannot read property 'nodeName' of null at eval (eval at webpackJsonp.../../../../script-loader/addScript.js.module.exports ( http://localhost:4200/0.chunk.js:6326:8 ), :159:258)错误错误:未捕获(承诺):TypeError:无法读取 null 的属性 'nodeName' TypeError:无法在 eval 中读取 null 的属性 'nodeName'(eval at webpackJsonp.../../../../script- loader/addScript.js.module.exports ( http://localhost:4200/0.chunk.js:6326:8 ), :159:258)

在此处输入图片说明

My package.json:我的 package.json:

{
  "name": "projectName",
  "version": "1.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "build:dev": "./node_modules/.bin/ng build",
    "build:prod": "./node_modules/.bin/ng build --prod --aot=false",
    "build:aot": "./node_modules/.bin/ng build --prod --aot",
    "build:aot2": "node --max_old_space_size=4096 ./node_modules/.bin/ng build --prod --aot",
    "build": "npm run build:dev",
    "clean:dist": "npm run rimraf -- dist",
    "clean:install": "npm set progress=false && npm install",
    "clean:start": "npm start",
    "clean": "npm cache clean && npm run rimraf -- node_modules doc coverage dist",
    "e2e:live": "npm run e2e -- --elementExplorer",
    "e2e": "npm run protractor",
    "lint": "npm run tslint \"src/**/*.ts\"",
    "postversion": "git push && git push --tags",
    "prebuild:dev": "npm run clean:dist",
    "prebuild:prod": "npm run clean:dist",
    "preclean:install": "npm run clean",
    "preclean:start": "npm run clean",
    "preversion": "npm test",
    "protractor": "protractor",
    "rimraf": "rimraf",
    "server:dev": "./node_modules/.bin/ng serve",
    "server": "npm run server:dev",
    "start": "npm run server:dev",
    "test": "./node_modules/.bin/ng test",
    "tslint": "tslint",
    "typedoc": "typedoc",
    "version": "npm run build",
    "ng": "ng",
    "pree2e": "webdriver-manager update --standalone false --gecko false"
  },
  "private": true,
  "dependencies": {
    "@angular-redux/store": "^6.4.5",
    "@angular/animations": "^4.2.2",
    "@angular/cli": "^1.1.1",
    "@angular/common": "^4.2.2",
    "@angular/compiler": "^4.2.2",
    "@angular/compiler-cli": "^4.2.2",
    "@angular/core": "^4.2.2",
    "@angular/forms": "^4.2.2",
    "@angular/http": "^4.2.2",
    "@angular/platform-browser": "^4.2.2",
    "@angular/platform-browser-dynamic": "^4.2.2",
    "@angular/router": "^4.2.2",
    "X-editable": "github:vitalets/x-editable",
    "angular-2-dropdown-multiselect": "^1.3.2",
    "bootstrap": "3.3.7",
    "bootstrap-colorpicker": "2.5.1",
    "bootstrap-duallistbox": "3.0.6",
    "bootstrap-markdown": "2.10.0",
    "bootstrap-progressbar": "0.9.0",
    "bootstrap-slider": "^9.8.0",
    "bootstrap-tagsinput": "0.7.1",
    "bootstrap-timepicker": "0.5.2",
    "chart.js": "2.6.0",
    "classlist.js": "^1.1.20150312",
    "clockpicker": "0.0.7",
    "clone": "2.1.1",
    "core-js": "2.4.1",
    "debounce": "^1.0.2",
    "dropzone": "^5.1.0",
    "dygraphs": "2.0.0",
    "fuelux": "^3.16.0",
    "he": "1.1.1",
    "highcharts": "5.0.12",
    "intl": "^1.2.5",
    "ion-rangeslider": "2.1.7",
    "jquery": "^3.2.1",
    "jquery-color": "1.0.0",
    "jquery-jcrop": "0.9.13",
    "jquery-knob": "1.2.11",
    "jquery-ui-npm": "1.12.0",
    "jquery-validation": "1.16.0",
    "jquery.maskedinput": "1.4.1",
    "markdown": "0.5.0",
    "morris.js": "0.5.0",
    "ng2-datetime": "https://github.com/elt/ng2-datetime/tarball/dynamic_template",
    "ng2-logger": "^1.0.3",
    "ngx-bootstrap": "^1.7.1",
    "ngx-popover": "0.0.16",
    "nouislider": "10.0.0",
    "raphael": "2.2.7",
    "redux": "^3.6.0",
    "rxjs": "^5.4.0",
    "scriptjs": "2.5.8",
    "select2": "4.0.3",
    "smartadmin-plugins": "^1.0.20",
    "summernote": "^0.8.4",
    "to-markdown": "3.0.4",
    "ts-helpers": "1.1.2",
    "web-animations-js": "^2.2.5",
    "webpack": "^2.6.1",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@types/jasmine": "2.5.52",
    "@types/jquery": "2.0.46",
    "@types/node": "7.0.31",
    "codelyzer": "3.0.1",
    "css-loader": "0.28.4",
    "exports-loader": "0.6.4",
    "expose-loader": "0.7.3",
    "file-loader": "0.11.2",
    "imports-loader": "0.7.1",
    "jasmine-core": "2.6.3",
    "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.3.0",
    "karma-jasmine": "1.1.0",
    "karma-jasmine-html-reporter": "0.2.2",
    "karma-remap-istanbul": "0.6.0",
    "protractor": "5.1.2",
    "raw-loader": "0.5.1",
    "script-loader": "^0.7.0",
    "style-loader": "0.18.2",
    "ts-node": "3.0.6",
    "tslint": "5.4.3",
    "typescript": "2.3.4",
    "url-loader": "0.5.9"
  },
  "engines": {
    "node": ">= 4.2.1",
    "npm": ">= 3"
  }
}

In a desperate attempt, I reinstalled: script-loader dependency, just to be sure.在绝望的尝试中,我重新安装了: script-loader依赖项,只是为了确定。

I am pretty clueless, any tip or advice or even solution would be much appreciated!我很无能,任何提示或建议甚至解决方案都将不胜感激!

Thanks in advice!谢谢指教!

Update 1:更新 1:

I have posted a more clear and updated image of the error that I find in console.我已经发布了我在控制台中发现的错误的更清晰和更新的图像。

When I click on those errors (See code line 6329), I get here:当我点击这些错误(见代码行 6329)时,我会到这里:

在此处输入图片说明

If anybody has a clue of what is causing the error or even know a good way to debug it and find the issue it would be of great help!如果有人知道导致错误的原因,或者甚至知道调试它并找到问题的好方法,那将有很大帮助!

I have found the issue: DataTables .我发现了问题: DataTables

I'm using the DataTables library, and is having an issue with the initialization of the table.我正在使用 DataTables 库,并且在表的初始化方面遇到了问题。

I could not fix the DataTables issue yet, but this is the source of the error.我还无法修复 DataTables 问题,但这是错误的根源。

So, in order to make this question useful and don't delete it I'll explain how I got to that conclusion:因此,为了使这个问题有用并且不要删除它,我将解释我是如何得出这个结论的:

  1. TypeError: Cannot read property 'nodeName' of null is typical in jQuery, so, start searching in your main jQuery libraries is a good option. TypeError: Cannot read property 'nodeName' of null在 jQuery 中是典型的,所以,开始在你的主要 jQuery 库中搜索是一个不错的选择。
  2. After navigating and seing that it was happening only in that view, I started analyzing 1 by 1 all the components of that view.在导航并看到它仅在该视图中发生后,我开始 1 对 1 分析该视图的所有组件。
  3. Reinstall your npm packages.重新安装你的 npm 包。 If you did a huge upgrade of your project, removing node_modules and typing npm install in console can be of help (even if drastic, but helped me).如果您对项目进行了大规模升级,删除node_modules并在控制台中键入npm install可能会有所帮助(即使很激烈,但对我有帮助)。
  4. Use Chrome's debugger.使用 Chrome 的调试器。
  5. Use console logs.使用控制台日志。
  6. If you are using a theme, and this theme is working properly.如果您正在使用一个主题,并且该主题工作正常。 Try to break it adding your stuff one at a time until it breaks.尝试打破它一次添加你的东西,直到它打破。 There has to be a reason for your App breaking but your App's theme not breaking.您的应用程序中断必须有一个原因,但您的应用程序主题没有中断。
  7. Compare projects (the theme's project and yours) in order to point out potential code issues.比较项目(主题的项目和您的项目)以指出潜在的代码问题。

I hope this may help someone that's stuck with this issue for a while.我希望这可以帮助那些被这个问题困扰了一段时间的人。

Breaking my App to find the issue I have found that many libraries throw this error, all of them were jQuery based libraries. Breaking my App to find the issue 我发现很多库都会抛出这个错误,它们都是基于 jQuery 的库。

Good luck!祝你好运!

Make sure your table has the same element count in thead, tbody, tfoot.确保您的表在 thead、tbody、tfoot 中具有相同的元素计数。 If you have 10 headers, 10 body columns, but 9 footers, it will not find the footer node and you will see the error.如果您有 10 个标题、10 个正文列,但有 9 个页脚,它将找不到页脚节点,您将看到错误。 Common mistake would be adding additional column, but forgetting adding the footer (if any).常见的错误是添加额外的列,但忘记添加页脚(如果有)。

I had this issue when working with an hybrid app (AngularJS and Angular) in a migration process.我在迁移过程中使用混合应用程序(AngularJS 和 Angular)时遇到了这个问题。

In my downgrade file, a component was declared twice :在我的降级文件中,一个组件被声明了两次

angular.module('myApp')
    ...
    .directive(
        'myDowngradedComponent',
        downgradeComponent({ component: myDowngradedComponent }) as angular.IDirectiveFactory
    )
    ...
    .directive(
        'myDowngradedComponent',
        downgradeComponent({ component: myDowngradedComponent }) as angular.IDirectiveFactory
    )
    ...

The number of tfoot columns doesn't match the number of thead columns. tfoot列的数量与thead列的数量不匹配。 That is likely the issue.这很可能是问题所在。

Ref: https://datatables.net/forums/discussion/50611/cannot-read-property-nodename-of-null-when-i-am-adding-row-in-tfoot参考: https : //datatables.net/forums/discussion/50611/cannot-read-property-nodename-of-null-when-i-am-adding-row-in-tfoot

Thanks谢谢

Removing responsive: true (a property that I'm no longer using) from DataTable({...}) fixed it.DataTable({...})删除responsive: true (我不再使用的属性DataTable({...})修复了它。


Extra details:额外的细节:

package.json : package.json :

...
"datatables.net-bs4": "^1.10.20",
"datatables.net-responsive-bs4": "^2.2.3",
"datatables.net-rowgroup-bs4": "^1.1.1",
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular 2 TypeError:无法读取null的属性“动画” - Angular 2 TypeError: Cannot read property 'animate' of null Angular TypeError:无法读取 null 的属性“用户” - Angular TypeError: Cannot read property 'users' of null TypeError:无法读取null angular的属性'form' - TypeError: Cannot read property 'form' of null angular 错误TypeError:无法读取null的属性“ 0” 角度7 - ERROR TypeError: Cannot read property '0' of null | Angular 7 Angular:TypeError:无法读取 null 的属性“firstCreatePass” - Angular: TypeError: Cannot read property 'firstCreatePass' of null Angular 6:TypeError:无法读取 null 的属性“scrollIntoView” - Angular 6: TypeError: Cannot read property 'scrollIntoView' of null TypeError:无法读取空角度6的属性“ postalCode” - TypeError : cannot read property 'postalCode' of null angular 6 Angular 4 - TypeError:无法读取null的属性“length” - Angular 4 - TypeError: Cannot read property 'length' of null 类型错误:无法读取 null 的属性“配置文件”类型错误:无法使用身份服务器 4 在 Angular 中读取 null 的属性“配置文件” - TypeError: Cannot read property 'profile' of null TypeError: Cannot read property 'profile' of null in Angular using idenity Server 4 未捕获的TypeError:无法读取null Angular 6的属性'addEventListener' - Uncaught TypeError: Cannot read property 'addEventListener' of null Angular 6
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM