Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

[npm3] Install with a symlinked module results in lots of warnings (for no reason) #9999

Closed
stefanr opened this issue Oct 16, 2015 · 6 comments

Comments

@stefanr
Copy link

stefanr commented Oct 16, 2015

During a npm install all modules in node_modules will be analyzed to build up the ideal dependency tree ... as far as I understand ...

But this doesn't make any sense for modules that are symlinked. This is also realized by npm and results in a bunch of warn messages:

npm WARN skippingAction Module is inside a symlinked module: not running add ...

So why analyzing this modules anyway? Wouldn't it make sense to filter these out in an earlier install step. Because besides being unnecessary it also takes a lot of time, depending on the size of the module of course.

@i-e-b
Copy link

i-e-b commented Nov 11, 2015

This seems to result in the situation where you have module A which depends on B and C, and C also depends on B, with de-duplication you would expect

A
    B
    C

but if C is put in place by npm link then you get

A
    C
        B

which is non-functional.
Possibly related to #9689
and #10013

@stefanr
Copy link
Author

stefanr commented Nov 11, 2015

Actually I expect npm to ignore anything inside the symlinked folder because it isn't allowed to touch anything inside anyways. So the case is more like this:

I have a symlinked module called S and two modules called A and B which also depend on S. S is already present in node_modules as a symlinked folder. S if A and B are installed and the version of S matches the version needed by A and B it will not be installed. And since S is symlinked it shouldn't be inspected for de-duplication.

i-e-b added a commit to i-e-b/npm-workspace that referenced this issue Nov 13, 2015
npm v3 has broken a few behaviours that `npm-workspace` relies on.

- Peer dependencies:
  These are no longer installed by default. When `npm-workspace`
  explicitly adds these, they remain functional. Test have been updated to
  reflect new behaviour.

- Linked dependency flattening ( npm/npm#10343
  and npm/npm#10348 and
  npm/npm#9999 )
  npm v3 does not correctly install dependencies that are shared between a
  package and its sym-linked dependency.
```
  A
  +- B (linked)
  |  +- C
  +- C
```
  Should result in both `A` and `B` getting a copy of `C`, however it
  results in:
```
  A
  +- B (linked)
     +- C
```
  To work around this, npm-workspace now adds 'dummy' packages for ones it
  will link, then runs `npm i` then replaces the dummy packages with the
  real symlinks. This results in a complete and correct install.
  Due to a change in the way npm checks versions after npm 3, the dummy
  packages need to be different, so the npm version is read at the start
  of an install.
@tellnes
Copy link

tellnes commented Dec 18, 2015

+1 what @stefanr said. If a module is symlinked in the node_modules, I expect npm not to touch anything inside it.

@stevage
Copy link

stevage commented Jan 12, 2016

This is pretty infuriating. Since upgrading to npm3, I'm now getting hundreds of lines of spam when doing any npm operation:

npm WARN skippingAction Module is inside a symlinked module: not running remove adm-zip@0.4.7 node_modules/terriajs/node_modules/adm-zip
npm WARN skippingAction Module is inside a symlinked module: not running remove after@0.8.1 node_modules/terriajs/node_modules/after
npm WARN skippingAction Module is inside a symlinked module: not running remove ansi-regex@2.0.0 node_modules/terriajs/node_modules/ansi-regex
...

The module in question (terriajs) was npm linked the standard way - I don't think I'm doing anything that is not standard.

@jdrydn
Copy link

jdrydn commented Jan 13, 2016

+1 to what @stefanr and @tellnes said - it makes building submodules a real pain and made the migration from 0.12 to 4.0 unnecessarily difficult 😢

@micimize
Copy link

I wrapped npm in a filter function to avoid this problem:

function npms { #`s` for symlink
    npm $@ --color=always 2>&1 | grep -vE 'Module is inside a symlinked module'
}

Another helpful utility:

function npm-ls-linked-deps {
    ls -l node_modules | \
        grep ^l | \
        awk '{print $9}' | \
        sed 's/@//g';
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants