Workspace links #485
-
Hi, Let's make an example:
all the projects are linked to each other by default. Running:
lead to installing an npm's module fetch from the registry. yarn has the Is it possible to do the same within npm workspaces? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There's a couple ways to do this. The first is that you can specify a relative path (if you're working locally) vs. using the name of the workspace (since npm will try to fetch from the registry - as you noticed) or you can you use Example 1 - relative path$ npm pkg set dependencies[c]="file:../c" -w a -w b
$ npm install Example 2 - link$ npm pkg set dependencies[c]="*" -w a -w b
$ npm link -w c
$ npm link c -w a -w b
$ npm install I mocked these out quickly so let me know if you run into any issues with either strategy |
Beta Was this translation helpful? Give feedback.
There's a couple ways to do this. The first is that you can specify a relative path (if you're working locally) vs. using the name of the workspace (since npm will try to fetch from the registry - as you noticed) or you can you use
npm link
(ref. https://docs.npmjs.com/cli/v7/commands/npm-link#workspace-usage & https://docs.npmjs.com/cli/v7/using-npm/workspaces). In both cases you'll want to add the dep but not install it. Since we don't have a great way of doing that today, you can usenpm pkg set
.Example 1 - relative path
Example 2 - link