1

I have Project and Component (both React based). Both are local and i do not want to publish them yet. I'm trying to include the Component into the Project by installing it with npm i.

In case i try to install the Component from tarball npm i file:../component-1.0.0.tgz (after npm pack) everything works as expected.
In case i try to install it from the folder npm i file:../component i get error at project start:
ModuleNotFoundError: Module not found: Error: Can't resolve 'react' in '/home/user/www/component/lib
React is the peer-dependency in the Component, obviously.

I want to modify the Component during the development of the Project. How can i install the Component from the folder?
Please do not suggest me to import Component from the source, this is important to not modify any line in the Project.

Serge
  • 665
  • 1
  • 4
  • 15
  • Perhaps consider utilizing [`npm link`](https://docs.npmjs.com/cli/link.html) instead. – RobC Dec 26 '19 at 12:03
  • `npm i file:../folder` in fact does exactly `npm link` does. This is not the solution. – Serge Dec 26 '19 at 13:02
  • See [difference between `npm link x` and `npm install /path/to/x`](https://stackoverflow.com/questions/50674052/difference-between-npm-link-x-and-npm-install-path-to-x). Presumably when you say both are _"exactly"_ you mean they both give you the same error ? – RobC Dec 26 '19 at 13:14
  • Yes, i know the difference, but for my question this doesn't matter. The problem is that if copy the Component into node_modules everything works. If i symlink the Component, no matter how, via `npm link` or via `npm i folder` - it doesn't. – Serge Dec 26 '19 at 13:28

0 Answers0