Open unional opened 6 months ago
I'm seeing the same thing with a selection of files that we deep copy with Vite from a third party library into our public assets folder. One of the folders has a package.json
inside of it which is being picked up by NX and breaking our builds even though it's not defined as a project.
I have the same issue that looks like:
Error: The following projects are defined in multiple locations:
4.255 - @core/application:
4.255 - .nx/tmp/681210077380676172/outputs/dist/libs/core/application
4.255 - dist/libs/core/application
4.255 - @core/common:
4.255 - .nx/tmp/12506113542676405020/outputs/dist/libs/core/common
4.255 - dist/libs/core/common
...
My cacheDirectory
in nx.json
looks like: "cacheDirectory": ".nx/tmp",
Nx automatically excludes directories which are gitignored, which I'd expect both your cache dir and dist to be.
For plugins configured in nx.json, you can exclude config globs like so:
plugins: [{ plugin: 'myPlugin', exclude: ['libs'] }]
would configure myPlugin to ignore config files in libs dir
I'm not using any plugins. In my case, those folders are .gitignore
in the respective package, not in the root's .gitignore
.
@AgentEnder Good to know, thanks! I really had only a .gitignore file one folder above of my root and not in the root itself. But that didn't solve my problem. I updated yesterday to the newest nx version. That fixed the problem at the moment. Thanks!
i am not yet able to solve this issue
in my case I'm deploying firebase functions project. And it contains package.json
when builds into ./dist/apps/
And I got similar error
The following projects are defined in multiple locations:
2024-04-27T19:01:31.7584481Z
2024-04-27T19:01:31.7586404Z - <REDACTED>:
2024-04-27T19:01:31.7586741Z - apps/<REDACTED>
2024-04-27T19:01:31.7587318Z - dist/apps/<REDACTED>
2024-04-27T19:01:31.7602507Z
2024-04-27T19:01:31.7603472Z To fix this, set a unique name for each project in a project.json inside the project's root. If the project does not currently have a project.json, you can create one that contains only a name.
To fix that I just created a fake project.json
file in ./dist/apps/
with fake project name
cat << EOF > ./dist/apps/<REDACTED>/project.json
{
"name": "fake-project-name"
}
EOF
Description
Provide a way to exclude folders from project detection.
Motivation
Currently I'm getting these errors:
This is because there is a
project.json
understorybook-static
, which is generated bystorybook
for its own use.nx
saw that file and assume it isnx
'sproject.json
..nxignore
is only used for input/affected detection and does not help in this case.Suggested Implementation
The most user friendly way is to respect the workspace/pnpm-workspace/lerna config and don't reach in to look for any
project.json
. i.e. consider this as a bug instead of a feature.Alternate Implementations
Allow user to use
.nxignore
to exclude folder for this purpose.