17

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...).

1 Answer 1

6

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.

4
  • 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@<LOCAL_VERSION>
    – forgetso
    Commented Jul 21, 2022 at 20:17
  • 1
    it may be marked as fixed, but it sure isn't, not even in node 20
    – Phil
    Commented Nov 30, 2023 at 23:13
  • @Phil, I'm not on the npm maintenance team, so cannot say for sure, but I would guess that opening a new issue on GitHub with all the symptoms you observe would be the best course of action. I'm not using node 20 yet, so I cannot contribute much to the discussion, unfortunately.
    – ob-ivan
    Commented Dec 1, 2023 at 10:40
  • 1
    @ob-ivan sorry, my bad. It actually is working, I just had wrong package name in the package.json (my package folder was "something" but the actual package-name was "@my-org/something").
    – Phil
    Commented Dec 2, 2023 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.