Today I Learned ...

... npm config and Workspaces

npm workspaces can be a handy thing: They’re a small, under-appreciated feature that let’s you create a simple mono-repo with a single entry in your package.json file.

There’s one thing that recently got me confused though: I had one app inside a workspace that used a custom npm registry. I tried to set the registry url using a local .npmrc file but it didn’t work. Had I looked more closely I would’ve seen the little ENOWORKSPACES message. Turns out npm ignores the local config if there is a different setting for the whole repository. I think it kind of makes sense due to potential conflicts in the overall mono-repo.

npm Docs: Workspaces

Tags: