3

I work on two repositories at once. One depends on the other (listed in package.json dependencies).

So I am using npm link ..\theOne in other to work on both modules at once. As a result I can test the modification on one module on the other. Problem is when doing npm shrinkwrap on this other module: it will generate errors like:

npm ERR! extraneous C:\other\node_modules\theOne\node_modules\{xxxx}

{xxxx} is a dev dependencies that appears as extraneous for npm.

Anyone has succeded to shrinkwrap a module with symlink to another modules?

NB:

  • npm 3.10.3
  • node 6.3.0
Damien Leroux
  • 11,177
  • 7
  • 43
  • 57

1 Answers1

0

I post a solution here. It doesn't explain how to shrinkwrap symlinks but I found a better workaround to develop multiple modules at once with dependencies between those modules.

The solution is to use an alternative to npm link to handle the modules relations during development: Instead of having a folder A linked to another folder B (aka symlink), the solution is to have the modified files from B copied in folder A. This solution is very powerful because it avoid getting node module shrinkwrapping error due to unwanted modules from B. How to do it:

On Mac

You can use wml: Wml listens to changes in some folder (using Watchman) and copies changed files into another folder. I never use it but my teammate using Mac use it every day.

On Window

I use DSynchronize (after clicking this link, scroll down to see the executable). DSynchronize is a stand-alone utility that let you periodically synchronize two or more folders. You can exclude from copying some folders (like node_modules) or include others (like lib). The configuration file DSynchronize.ini can be edited with a text editor. For example:

Source0000=-C:\DEV\workspace\js-common
Destination0000=-C:\DEV\workspace\connexme\node_modules\js-common
Filter0000=
VolumeSerialOri0000=407325536
VolumeSerialDest0000=407325536
ExcludeFilter0000=0
NoSubDirectory0000=0
NoFilterDirectory0000=1
DateBeforeToExcludeFiles0000=00:00:00
FilterFolder0000=\.git|\.vscode|\node_modules

This configuration will copy file from C:\DEV\workspace\js-common to C:\DEV\workspace\connexme\node_modules\js-common. This way, when I npm shrinkwrap my project connexme, I'll doesn't get extraneous bad folder from js-common folder.

Just a three last things about editing DSynchronize.ini for DSynchronize configuration:

  • Using it or closing it will save the configuration in DSynchronize.ini so be careful when editing DSynchronize.iniand the closing it. It will override DSynchronize.ini.
  • Make sure each variables is unique. Example: Source0000, Source0001...
  • Make sure to have all the variables present for each Source/Destinations (see example above).
Community
  • 1
  • 1
Damien Leroux
  • 11,177
  • 7
  • 43
  • 57