nrwl / nx

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

Cannot find project 'web' #28123

Open mdungmc opened 2 months ago

mdungmc commented 2 months ago

Current Behavior

Anytime I run npm start web, i always got: Cannot find project 'web'

Expected Behavior

I just want to run the project

GitHub Repo

No response

Steps to Reproduce

Firstly I ran project successfully, but accidentally, the project is crashed like now.

Nx Report

Node           : 20.15.1
OS             : win32-x64
Native Target  : wasm32
npm            : 10.7.0

nx (global)        : 19.8.2
nx                 : 19.7.3
@nx/js             : 19.7.3
@nx/jest           : 19.7.3
@nx/linter         : 19.7.3
@nx/eslint         : 19.7.3
@nx/workspace      : 19.7.3
@nx/devkit         : 19.7.3
@nx/eslint-plugin  : 19.7.3
@nx/nest           : 19.7.3
@nx/node           : 19.7.3
@nx/react          : 19.7.3
@nrwl/tao          : 19.7.3
@nx/vite           : 19.7.3
@nx/web            : 19.7.3
@nx/webpack        : 19.7.3
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin
@nx/jest/plugin
@nx/webpack/plugin
nx/plugins/package-json

Failure Logs

Admin@Maduro MINGW64 /d/Workspace/caai (main)
$ npm start web

> caia@0.0.0 start
> nx serve web

 NX   The Nx Daemon is unsupported in WebAssembly environments. Some things may be slower than or not function as expected.

 NX   Cannot find project 'web'

Package Manager Version

npm 20.15.1

Operating System

Additional Information

No response

binarybro commented 2 months ago

Same here. Since yesterday nx does not see any projects in nx workspaces anymore on my system. That also happens when I create an entirely new workspace usingnpx create-nx-workspace to create a fresh workspace. It seems the graph does not yield any projects in the workspace.

Scaffolding a new project using npx nx g @nrwl/angular:application some-project will add a project to the graph, which then shows up. However, if I delete the .nx folder in the workspace, that project is also never reflected on the graph again. It seems graph creation is broken.

I am on MacOS 15.

Node : 20.17.0 OS : darwin-arm64 Native Target : aarch64-macos yarn : 4.5.0

nx : 19.8.2 @nx/js : 19.8.2 @nx/jest : 19.8.2 @nx/linter : 19.8.2 @nx/eslint : 19.8.2 @nx/workspace : 19.8.2 @nx/angular : 19.8.2 @nx/devkit : 19.8.2 @nx/eslint-plugin : 19.8.2 @nrwl/tao : 19.8.2 @nx/web : 19.8.2 @nx/webpack : 19.8.2 typescript : 5.5.4

mdungmc commented 2 months ago

I tried to clone the project again, try to reinstall anything I can (Windows, npm, node, ...) but the problem have not repaired.

binarybro commented 2 months ago

same here: removed node, npm, yarn, eventually volta entirely. removed homebrew entirely. remove any plugins for zsh. any nx workspace i have on the system, nx appears to yield an empty graph.

binarybro commented 2 months ago

It does not matter what kind of project I create. react, angular all the same.

npx create-nx-workspace

% npx create-nx-workspace nx-test

 NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

✔ Which stack do you want to use? · react
✔ What framework would you like to use? · nextjs
✔ Integrated monorepo, or standalone project? · integrated
✔ Application name · nx-test
✔ Would you like to use the App Router (recommended)? · No
✔ Would you like to use the src/ directory? · Yes
✔ Test runner to use for end to end (E2E) tests · none
✔ Default stylesheet format · css
✔ Which CI provider would you like to use? · skip
✔ Would you like remote caching to make your build faster? · skip

 NX   Creating your v19.8.2 workspace.

✔ Installing dependencies with npm
✔ Successfully created the workspace: nx-test.

% nx show project nx-test      
Could not find project nx-test

% cat .nx/workspace-data/project-graph.json 
{
  "nodes": {},
  "externalNodes": {},
  "dependencies": {},
  "version": "6.0"
}
binarybro commented 2 months ago

In my case the culprit was a .gitignore file in a parent directory with a wildcard. That file is in my home directory, where I also have a projects directory. Apparently Nx considers a parent directory's .gitignore somehow. Anyways, for me this issue is resolved.

smilovanovic commented 2 months ago

In my case the culprit was a .gitignore file in a parent directory with a wildcard. That file is in my home directory, where I also have a projects directory. Apparently Nx considers a parent directory's .gitignore somehow. Anyways, for me this issue is resolved.

As stated by @binarybro .gitignore in my home dir was the problem because of the wildcard. Workspace works after the following steps:

rrrnld commented 1 month ago

In my case the culprit was a .gitignore file in a parent directory with a wildcard. That file is in my home directory, where I also have a projects directory. Apparently Nx considers a parent directory's .gitignore somehow. Anyways, for me this issue is resolved.

Thanks so much! I hit the same issue.

I think this is a bug in nx. I have my nx workspace in a directory tree that somewhere along the ladder has a parent folder that was also a git repository ignoring all of its subfolders, nx just mysteriously couldn't find any projects in the workspace.

nx should probably stop looking for parent .gitignores at the root of the repository / workspace?

This is the structure I had

/foo
/foo/.gitignore
/foo/bar
/foo/bar/pnpm-workspace.yml
/foo/bar/apps/
/foo/bar/apps/project-that-should-be-visible
# …

Both /foo and /foo/bar were git repositories. /foo/.gitignore contained a single line with */.

/foo/bar/pnpm-workspace.yml looks like this:

packages:
  - apps/*

/foo/bar is the nx repository, and no projects could be found, even though all subfolders were visible to the git repository in /foo/bar.

yaamisv commented 1 month ago

this is similar to https://github.com/nrwl/nx/issues/27368 reported few month ago, issue started from nx v19.5