'NX ERROR - Nx failed to install dependencies

I'm not sure what could be going wrong and the error message is blank whenever I open it. I've searched online for fixes but nothing has helped hence I'm asking here.

My version of node is: v16.1.0 My version of npm: 8.1.3

And I'm currently running Monterey OS on my M1 MacBook.

khalidn@Khalids-MacBook-Air Next % npx create-nx-workspace --preset=next
✔ Workspace name (e.g., org name)     · km
✔ Application name                    · site
✔ Default stylesheet format           · css
✔ Use Nx Cloud? (It's free and doesn't require registration.) · No

>  NX  Nx is creating your workspace.

  To make sure the command works reliably in all environments, and that the preset is applied correctly,
  Nx will run "npm install" several times. Please wait.

✖ Installing dependencies with npm

>  NX   ERROR  Nx failed to install dependencies

  Exit code: 1
  Log file: /var/folders/vk/k0pds4vn1cb7wf1jvbhdj79w0000gn/T/tmp-46552-0zjGtpc1VjRl/error.log

Has anyone else gone through this?



Solution 1:[1]

Alright I looked into it and the problem occurs when the full path to your nx repo has spaces in it.

Looking through the log that is generated the make compiler complains that a folder is missing and its due to the fact that its looking for that folder in the partial path.

I am not sure who is responsible for fixing this issue but the workaround would be to make sure your path to the nx repo does not have any spaces in it!

Solution 2:[2]

I was able to get it to work by installing it this way in the terminal:

npx create-nx-workspace [workspace name] \
--preset=next \
--style=css \
--appName=[app name]

Solution 3:[3]

On a Mac, this worked for me:

npm uninstall @nrwl/schematics; npm install -g @nrwl/schematics npm cache clean --force;npx create-nx-workspace@latest

Solution 4:[4]

What worked for me is to use version @13.9.3 instead of @latest.

npx [email protected]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Enrico
Solution 2 thursdaysboy
Solution 3 β.εηοιτ.βε
Solution 4 arn-arn