npm workspaces "WARN: some-package-name in filter set, but no workspace folder present"

Viewed 1545

I have a repo with many npm packages inside, using npm workspaces

The top-level package.json contains the line:

  "workspaces": [
    "*"
  ]

When I run npm i -ws or other npm commands, I receive the warning:

WARN: some-package-name in filter set, but no workspace folder present

I'm not quite sure what the message means - I think the 'filter set' is the -w option, but the workspace folder some-package-name definitely exists.

One note is that the some-package-name/package.json contains an org prefix, eg:

"name": "@mycompany/some-package-name",

So maybe that's the cause. I can't rename the folder from some-package-name to @mycompany/some-package-name though as I'm concerned a directory starting with @ may break things.

What does the warning mean and how can I resolve it?

2 Answers

I ran into the same problem, using the name configured in the workspace's package instead of the folder name fixed the issue for me, even with an @.

npm install --workspace=@mycompany/some-package-name

I solved this issue using a file: dependency as "recommended by npm"

Actually many articles say that npm recommends to use file: to reference a dependency between two workspace packages (and then often they use the asterisk anyway) but honestly I did not found that hint in npm docs, but it works! ... at least it worked for me, using the following

Explicitly list the workspaces

So instead of using an asterisk I have, for example

  "workspaces": [
    "packages/models",
    "packages/database",
    "webapp"
  ]

I also have a scoped package name

for instance

  "name": "@project/models",
  "private": "true"

I am using "file:" dependencies

Instead of

  "dependencies": {
    "@project/models": "*"
  }

I use file:WORKSPACE_PATH

  "dependencies": {
    "@project/models": "file:packages/models"
  }
Related