nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.56k stars 2.36k forks source link

Error while loading rule '@nrwl/nx/enforce-module-boundaries' #6494

Closed Drovosek01 closed 3 years ago

Drovosek01 commented 3 years ago

Current Behavior

When opening any .ts (Typescript) file in a project on Angular 11 I get an ESLint error. TypeError: Error while loading rule '@nrwl/nx/enforce-module-boundaries': Cannot read property 'nodes' of null

Expected Behavior

There was no such error before, it began to appear after I pulled new changes from the project branch. This error only appears in my WebStorm 2021.1.3, but there is no such error in VSCode 1.58.2.

Steps to Reproduce

Unfortunately, I do not know how to reproduce this error and I can not share the repository with the project.

Failure Logs

TypeError: Error while loading rule '@nrwl/nx/enforce-module-boundaries': Cannot read property 'nodes' of null
Occurred while linting private_path\apps\client-office\src\polyfills.ts

TypeError: Error while loading rule '@nrwl/nx/enforce-module-boundaries': Cannot read property 'nodes' of null
Occurred while linting private_path\apps\client-office\src\polyfills.ts
    at create (private_path\node_modules\@nrwl\eslint-plugin-nx\src\rules\enforce-module-boundaries.js:76:106)
    at Object.create (private_path\node_modules\@typescript-eslint\experimental-utils\dist\eslint-utils\RuleCreator.js:13:24)
    at createRuleListeners (private_path\node_modules\eslint\lib\linter\linter.js:761:21)
    at private_path\node_modules\eslint\lib\linter\linter.js:931:31
    at Array.forEach (<anonymous>)
    at runRules (private_path\node_modules\eslint\lib\linter\linter.js:876:34)
    at Linter._verifyWithoutProcessors (private_path\node_modules\eslint\lib\linter\linter.js:1175:31)
    at private_path\node_modules\eslint\lib\linter\linter.js:1299:29
    at Array.map (<anonymous>)
    at Linter._verifyWithProcessor (private_path\node_modules\eslint\lib\linter\linter.js:1294:65)
Process finished with exit code -1

image

Environment

The error appears in Webstorm 2021.1.3 on Windows 10 x86_64. When viewing files in VSCode 1.58.2 with the "Angular Language Services" and "ESLint" extensions installed, there is no such error.

package.json deps

"dependencies": {
    "@angular/animations": "11.2.0",
    "@angular/cdk": "11.2.0",
    "@angular/common": "11.2.0",
    "@angular/compiler": "11.2.0",
    "@angular/core": "11.2.0",
    "@angular/forms": "11.2.0",
    "@angular/platform-browser": "11.2.0",
    "@angular/platform-browser-dynamic": "11.2.0",
    "@angular/router": "11.2.0",
    "@aspnet/signalr": "^1.1.4",
    "@ng-web-apis/common": "^1.12.0",
    "@ngneat/until-destroy": "^8.0.4",
    "@ngxs-labs/immer-adapter": "^3.0.5",
    "@ngxs/devtools-plugin": "^3.6.2",
    "@ngxs/form-plugin": "^3.6.2",
    "@ngxs/storage-plugin": "^3.6.2",
    "@ngxs/store": "^3.6.2",
    "@nrwl/angular": "12.0.0",
    "angular-imask": "^6.0.4",
    "angularx-qrcode": "10.0.10",
    "core-js": "^3.6.4",
    "csvtojson": "^2.0.10",
    "http-status-codes": "^1.3.0",
    "imask": "^6.0.3",
    "immer": "^6.0.2",
    "jsbarcode": "^3.11.0",
    "ng-circle-progress": "^1.5.1",
    "ng2-pdf-viewer": "^6.3.2",
    "raven-js": "^3.27.2",
    "rrweb": "^0.8.2",
    "rrweb-player": "^0.4.3",
    "rxjs": "~6.6.3",
    "tslib": "^2.2.0",
    "uuid": "^3.4.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "0.1102.8",
    "@angular-eslint/eslint-plugin": "~2.0.2",
    "@angular-eslint/eslint-plugin-template": "~2.0.2",
    "@angular-eslint/template-parser": "~2.0.2",
    "@angular/cli": "11.2.0",
    "@angular/compiler-cli": "11.2.0",
    "@angular/language-service": "11.2.0",
    "@babel/core": "^7.6.4",
    "@nrwl/cli": "12.0.0",
    "@nrwl/eslint-plugin-nx": "12.0.0",
    "@nrwl/jest": "12.0.0",
    "@nrwl/linter": "12.0.0",
    "@nrwl/tao": "12.0.0",
    "@nrwl/workspace": "12.0.0",
    "@storybook/addon-actions": "^6.1.18",
    "@storybook/addon-backgrounds": "^6.1.18",
    "@storybook/addon-centered": "^5.3.21",
    "@storybook/addon-knobs": "^6.1.18",
    "@storybook/addon-links": "^6.1.18",
    "@storybook/addon-notes": "^5.3.21",
    "@storybook/addon-options": "^5.3.21",
    "@storybook/addon-storyshots": "^6.1.18",
    "@storybook/addon-storysource": "^6.1.18",
    "@storybook/addons": "^6.1.18",
    "@storybook/angular": "^6.1.18",
    "@types/jest": "26.0.8",
    "@types/node": "14.14.33",
    "@types/uuid": "^3.4.7",
    "@typescript-eslint/eslint-plugin": "4.19.0",
    "@typescript-eslint/parser": "4.19.0",
    "babel-loader": "^8.0.6",
    "css-loader": "^2.1.0",
    "dotenv": "8.2.0",
    "eslint": "^7.22.0",
    "eslint-config-prettier": "8.1.0",
    "eslint-plugin-import": "latest",
    "eslint-plugin-rxjs": "latest",
    "git-last-commit": "^1.0.0",
    "husky": "^4.3.5",
    "jest": "26.2.2",
    "jest-marbles": "^2.5.1",
    "jest-preset-angular": "8.3.2",
    "lint-staged": "^10.5.3",
    "moment": "^2.24.0",
    "prettier": "2.2.1",
    "pretty-quick": "^3.1.0",
    "protractor": "7.0.0",
    "sass-loader": "^7.1.0",
    "to-string-loader": "^1.1.5",
    "ts-jest": "26.4.0",
    "ts-node": "9.1.1",
    "typescript": "4.1.4",
    "webpack-bundle-analyzer": "^3.6.1"
  },
  "jest": {
    "preset": "jest-preset-angular",
    "setupTestFrameworkScriptFile": "<rootDir>/tools/jest/setupJest.ts"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged && pretty-quick --staged --pattern '**/*.*(ts|html)'"
    }
  },
  "lint-staged": {
    "*.(ts|html)": "eslint --fix"
  }
FrozenPandaz commented 3 years ago

Hi, we've made some changes relating to this issue recently. Could you please retry with the latest version of Nx and see if the issue persists?

Drovosek01 commented 3 years ago

I do not know why and how, but today this error just knitted and disappeared by itself, although I did not change anything in the project at all.

Drovosek01 commented 3 years ago

I had to delete the entire project folder and clone it again. After I installed all the dependencies using yarn , I saw this error again. image I tried deleting the node_modules folder and downloading all the dependencies again several times - but it didn't help.

"dependencies": {
    "@angular/animations": "11.2.0",
    "@angular/cdk": "11.2.0",
    "@angular/common": "11.2.0",
    "@angular/compiler": "11.2.0",
    "@angular/core": "11.2.0",
    "@angular/forms": "11.2.0",
    "@angular/platform-browser": "11.2.0",
    "@angular/platform-browser-dynamic": "11.2.0",
    "@angular/router": "11.2.0",
    "@aspnet/signalr": "^1.1.4",
    "@ng-web-apis/common": "^1.12.0",
    "@ngneat/until-destroy": "^8.0.4",
    "@ngxs-labs/immer-adapter": "^3.0.5",
    "@ngxs/devtools-plugin": "^3.6.2",
    "@ngxs/form-plugin": "^3.6.2",
    "@ngxs/storage-plugin": "^3.6.2",
    "@ngxs/store": "^3.6.2",
    "@nrwl/angular": "^12.0.0",
    "angular-imask": "^6.0.4",
    "angularx-qrcode": "10.0.10",
    "core-js": "^3.6.4",
    "csvtojson": "^2.0.10",
    "http-status-codes": "^1.3.0",
    "imask": "^6.0.3",
    "immer": "^6.0.2",
    "jsbarcode": "^3.11.0",
    "ng-circle-progress": "^1.5.1",
    "ng2-pdf-viewer": "^6.3.2",
    "raven-js": "^3.27.2",
    "rrweb": "^0.8.2",
    "rrweb-player": "^0.4.3",
    "rxjs": "~6.6.3",
    "tslib": "^2.2.0",
    "uuid": "^3.4.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "0.1102.8",
    "@angular-eslint/eslint-plugin": "~2.0.2",
    "@angular-eslint/eslint-plugin-template": "~2.0.2",
    "@angular-eslint/template-parser": "~2.0.2",
    "@angular/cli": "11.2.0",
    "@angular/compiler-cli": "11.2.0",
    "@angular/language-service": "11.2.0",
    "@babel/core": "^7.6.4",
    "@nrwl/cli": "^12.0.0",
    "@nrwl/eslint-plugin-nx": "12.0.0",
    "@nrwl/jest": "^12.0.0",
    "@nrwl/linter": "^12.0.0",
    "@nrwl/tao": "^12.0.0",
    "@nrwl/workspace": "^12.0.0",
    "@storybook/addon-actions": "^6.1.18",
    "@storybook/addon-backgrounds": "^6.1.18",
    "@storybook/addon-centered": "^5.3.21",
    "@storybook/addon-knobs": "^6.1.18",
    "@storybook/addon-links": "^6.1.18",
    "@storybook/addon-notes": "^5.3.21",
    "@storybook/addon-options": "^5.3.21",
    "@storybook/addon-storyshots": "^6.1.18",
    "@storybook/addon-storysource": "^6.1.18",
    "@storybook/addons": "^6.1.18",
    "@storybook/angular": "^6.1.18",
    "@types/jest": "26.0.8",
    "@types/node": "14.14.33",
    "@types/uuid": "^3.4.7",
    "@typescript-eslint/eslint-plugin": "4.19.0",
    "@typescript-eslint/parser": "4.19.0",
    "babel-loader": "^8.0.6",
    "css-loader": "^2.1.0",
    "dotenv": "8.2.0",
    "eslint": "^7.22.0",
    "eslint-config-prettier": "8.1.0",
    "eslint-plugin-import": "latest",
    "eslint-plugin-prettier": "^3.4.0",
    "eslint-plugin-rxjs": "latest",
    "git-last-commit": "^1.0.0",
    "jest": "26.2.2",
    "jest-marbles": "^2.5.1",
    "jest-preset-angular": "8.3.2",
    "moment": "^2.24.0",
    "prettier": "2.2.1",
    "protractor": "7.0.0",
    "sass-loader": "^7.1.0",
    "to-string-loader": "^1.1.5",
    "ts-jest": "26.4.0",
    "ts-node": "9.1.1",
    "typescript": "4.1.4",
    "webpack-bundle-analyzer": "^3.6.1"
  },

I tried to update all packages with the word "nrwl" in the name, and I just added the "^" symbol to the name of such packages, and then updated the dependencies, but it didn't help.

What other ideas do you have on how to fix this error and why it appears?

I'm on WebStorm 2021.2 on Windows 10 20H2 x86_64

meeroslav commented 3 years ago

Hi @Drovosek01, can you tell us what is the installed version of the nx? You can find this out by running:

yarn nx --version

or by checking the version in package.json in one of the packages in the node_modules/@nrwl.

Unfortunately, without knowing the exact version there's not much we can say.

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.