14

Say I have the following structure

packages
  - @my-scope/packageA
  - @my-scope/packageB
  - @my-scope/packageC

Let's say I want to install packageA as a dependency of packageB. With NPM 8 workspaces I would think this ought to do it: npm install @my-scope/packageA --workspace=@my-scope/packageB

Instead I get this:

npm ERR! 404 Not Found - GET https://registry.npmjs.org/@my-scope%2fpackageA - Not found 
npm ERR! 404
npm ERR! 404  '@my-scope/packageA@*' is not in this registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

Clearly it is trying to get it from the registry (and no, I haven't published yet, not ready) but I want it to recognize that this dependency is in my project as a workspace. Anyone know why this might be happening? I haven't found many good resources explaining how to install dependencies from inside your monorepo (I don't even know what those are called...).

Andrew
  • 161
  • 1
  • 6

1 Answers1

5

The problem you are facing has been reported as a bug: https://github.com/npm/cli/issues/3637

It has been marked as fixed.

Please try to install the latest version of npm (8.8.0 as of this writing) and see if your problem has been resolved.

ob-ivan
  • 785
  • 1
  • 8
  • 17
  • If you're still hitting this error after updating npm, try removing the entry for packageA from the package.json of packageB. Then explicitly choose the local version when installing. `npm install @my-scope/packageA --workspace=@my-scope/packageB@` – forgetso Jul 21 '22 at 20:17