0

I'm trying to use npm link in my project App, I also have two libraries liba and libb.

  • my App uses both liba and libb
  • and my libb uses liba

Ihese are the commands I followed:

  1. npm link inside liba
  2. npm link inside libb
  3. npm link liba inside libb
  4. npm link liba && npm link libb inside the App.

but now when I run npm start in my App I get error in the import statement of liba saying that "Failed to install liba"

Also there is I don't see a reference to liba in node_modules of App, but I see reference of libb inside node_modules of App, and inside that liba.

In my App I am importing from liba as import { XYZ } from liba.

I get that error is coming because I don't have liba directly in the node_modules but inside node_modules/libb/liba.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
  • As [the documentation notes](https://docs.npmjs.com/cli/v8/commands/npm-link), `npm link` creates symlinks between folders and files; it doesn't make any changes to package.json. It also works at the global level, not at the app level, so you wouldn't see any changes at the app level. You'd probably be better off just adding references via package.json. – Heretic Monkey Dec 02 '22 at 01:25

0 Answers0