網站搜尋

javascript - 如何修復 nrwl nx 工作區的 spawn ENAMETOOLONG 錯誤


我一週前使用 nrwl/nx 生成了一個 Angular 專案,當時我可以生成函式庫和元件,並能啟動我的專案,但現在我收到以下錯誤:

spawn ENAMETOOLONG

每當我嘗試運行 npm run start 時就會發生此錯誤,目前它會運行 nx serve。ng serve 也無法運行。我可以運行 npm install,但無法啟動我的應用程序。如果你需要其他信息,我可以提供我的 package.json:

{
  "name": "moniesta-admin",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "postinstall": "node ./decorate-angular-cli.js && ngcc --properties es2015 browser module main",
    "start": "nx serve",
    "build": "nx build",
    "test": "nx test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~13.2.0",
    "@angular/cdk": "^13.0.0",
    "@angular/common": "~13.2.0",
    "@angular/compiler": "~13.2.0",
    "@angular/core": "~13.2.0",
    "@angular/forms": "~13.2.0",
    "@angular/localize": "~13.2.0",
    "@angular/material": "^13.2.2",
    "@angular/platform-browser": "~13.2.0",
    "@angular/platform-browser-dynamic": "~13.2.0",
    "@angular/router": "~13.2.0",
    "@nebular/auth": "^9.0.1",
    "@nebular/eva-icons": "^9.0.1",
    "@nebular/theme": "^9.0.1",
    "@ng-bootstrap/ng-bootstrap": "^11.0.0",
    "@nrwl/angular": "13.8.1",
    "bootstrap": "^5.1.3",
    "eva-icons": "^1.1.3",
    "rxjs": "~7.4.0",
    "tslib": "^2.0.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.2.0",
    "@angular-eslint/eslint-plugin": "~13.0.1",
    "@angular-eslint/eslint-plugin-template": "~13.0.1",
    "@angular-eslint/template-parser": "~13.0.1",
    "@angular/cli": "~13.2.0",
    "@angular/compiler-cli": "~13.2.0",
    "@angular/language-service": "~13.2.0",
    "@nrwl/cli": "13.8.1",
    "@nrwl/cypress": "13.8.1",
    "@nrwl/eslint-plugin-nx": "13.8.1",
    "@nrwl/jest": "13.8.1",
    "@nrwl/linter": "13.8.1",
    "@nrwl/tao": "13.8.1",
    "@nrwl/workspace": "13.8.1",
    "@schematics/angular": "~13.2.0",
    "@types/jest": "27.0.2",
    "@types/node": "16.11.7",
    "@typescript-eslint/eslint-plugin": "~5.10.0",
    "@typescript-eslint/parser": "~5.10.0",
    "cypress": "^9.1.0",
    "eslint": "~8.7.0",
    "eslint-config-prettier": "8.1.0",
    "eslint-plugin-cypress": "^2.10.3",
    "jest": "27.2.3",
    "jest-preset-angular": "11.0.0",
    "prettier": "^2.5.1",
    "ts-jest": "27.0.5",
    "typescript": "~4.5.2"
  }
}

編輯:

這種情況發生在我使用 nx reset 之後,再使用 nx serve 的時候:

   Log file with the error: C:\Users\Hasan\OneDrive\Desktop\Moniesta-Projects\Moniesta-Combinatioon\moniesta-management\moniesta-admin\node_modules\.cache\nx\d\daemon-error.log
   Please file an issue at https://github.com/nrwl/nx
   Nx Daemon is going to be disabled until you run "nx reset".

在守護程序日誌中,它只是顯示相同的錯誤:

 NX   spawn ENAMETOOLONG

答案#1

當你有太多未提交的檔案時(以我的經驗,大約超過700個左右),通常會出現此錯誤。提交這些檔案通常可以解決這個問題。

答案#2

我剛好遇到同樣的問題。我手動刪除了 node_modules 資料夾,然後用 npm install 重新安裝了一切。還發現根目錄中出現了一個新的 .angular 資料夾,之前並不存在。刪除這個資料夾後,我就能再次執行 build。不太確定如果執行一次 nx build(這會重新生成這個資料夾),是否應該再次刪掉它。