Npm link inside project subdirectory

This problem seems very specific, but I think it is very interesting to share, as it can help other people in a similar situation.

I help in developing the npm package (call lib). In the root directory of the project there is a folder called "examples" with mini-projects, using the library for testing. These projects may require a package via npm link (inside mini-projects), which is one of the recommended ways to test your package without constantly rebuilding it. The idea here is to save this folder inside the project.

The problem is that it creates an endless chain of folders, as shown below.

 -- lib ---- /examples ------ /project1 --------- /node_modules ----------- / lib ------------- /examples --------------- /project1 <--- see the infinite loop here ------------- ... ----------- ... ------ ... ---- index.js ---- package.json ---- .npmignore ---- ... 

This recursive connection gets confused with memory and blocks development, especially when working with the WebStorm IDE, which loops endlessly, "indexing files ...".

It seems that npm link does not take into account .npmignore (.gitignore) when creating the link. It also does not account for the files field if it is present in the package.json file.

Does anyone know a workaround for this?

+5
source share

Source: https://habr.com/ru/post/1243088/


All Articles