natyus
natyus

Reputation: 647

How to fix spawn ENAMETOOLONG error nrwl nx workspace

I generated a week ago an angular project with nrwl/nx at that time I could generate libs and components and could start my project but right now I am getting the following error:

spawn ENAMETOOLONG

This error occurs whenever I am trying to run npm run start which runs nx serve right now. ng serve is not working either. I can run npm install but nothing to start my application. Here is my package.json if you need any other information I can provide it:

{
  "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"
  }
}

EDIT:

This happens when i am using nx reset and after that using nx serve again:

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

In the Daemon log it just says the same error:

 NX   spawn ENAMETOOLONG

Upvotes: 19

Views: 16439

Answers (6)

Michael
Michael

Reputation: 71

In my case the reason was as @jurev described here, but the root cause of the problem was not so obvious.

I defined a local directory for a project and initialized local repo, then downloaded the project from remote repo into the directory and connected local repo with remote repo. As a result, I had nothing to commit but git status showed that all of the files are not staged for further commit and nx serve.. returned spawn ENAMETOOLONG.

For me the solution was deletion the whole project directory, downloading some client for version control system (for example, TortoiseGit) and clone the project from remote repo using the client and providing a link of the remote repo to it. After that nx serve worked perfectly.

Upvotes: 0

Labidi Aymen
Labidi Aymen

Reputation: 21

I don't know why it's related to GIT but yes, having too many uncommitted files is the main cause of the problem.

Upvotes: 2

jurev
jurev

Reputation: 1597

This error usually appears when you have too many uncommited files (in a range more than 700 or so in my experience). Commiting the files will usually solve the problem.

Upvotes: 47

Kamran Taghaddos
Kamran Taghaddos

Reputation: 614

I had the same issue and solve it like this:

First: Updating Nx to version 13.8.5. Do as below:

  1. Run command: nx migrate @nrwl/[email protected]
  2. Run command: npm install
  3. Run command: nx migrate --run-migrations
  4. Remove "migrations.json" file in nx workspace root directory

Second: Re-install npm globally based on nx version 13.8.5. Do as below:

  1. Run command: npm i -g [email protected]

Upvotes: 1

LH7
LH7

Reputation: 1423

I just ran into this issue. The solution that worked for me, I found it here

In my case, I was getting this error when running npm start, nx serve. After deleting the node_modules folder and running npm install, I found that running npm install was giving me this error too.

I had uncommitted changes on the branch. The error disappeared after committing the work.

Upvotes: 2

I just ran into the same issue. I did delete the node_modules folder manually, then re-installed everything with npm install. Also found that there is a new .angular folder in root folder, which was not present earlier. After deleting this folder entirely, I was able to run build again. Not really sure if running nx build once (which populates this folder again) you should not wipe it out once more.

Upvotes: 6

Related Questions