npm i --global-style

Aperta
#124 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
javascript, node.js
Ambito
tooling

Direzione di ricerca

Inizia con dependency-tree come punto di ingresso e riproduci l’invocazione usando dist/src/index.js, dist/node_modules/package2/index.js e i percorsi annidati di package1 mostrati nel report. Confronta il risultato con il comportamento di risoluzione dei moduli di Node.js e traccia il modo in cui vengono risolti gli argomenti di directory e nome file. Il lavoro è completato quando l’albero delle dipendenze riflette la disposizione del node_modules annidato più vicino descritta nell’output previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hello!

Maybe I'm creating an issue in the wrong repository and real problem hides somewhere in dependencies. But I use dependency-tree as an entry point, so ... it looks like a good start.

Let's imagine that we have the following directory layout:

<project>
  |
  - package.json
  - node_modules
  |    |
  |    - package1
  |         |
  |         - index.js
  |
  - dist <- dependency-tree `directory` argument
       |
       - package.json
       - src
            |
            - index.js  <- dependency-tree `filename` argument (path.join(..., 'dist', 'src', 'index.js'))
       - node_modules
            |
            - package2
                 |
                 - index.js
                 - node_modules
                      |
                      - package1
                           |
                           - index.js                      

I invoke dependency-tree with the following arguments:

{
  directory: path.join(<project>, 'dist'),
  filename: path.join(<project>, 'dist/src/index.js')
}

And index.js requires package2 module. Which, respectively, requires package1 module. The folder where package2 resides was initiated by the following command: npm i --global-style, i.e. dependencies of modules from package.json are put into local node_modules folders of each package. In other words - I want to maintain old-style node_modules directory layout (let's pretend that I like duplicates :) ), where each top-level module holds its modules with itself.

And here is the problem. Top level directory () also contains node_modules with package1. And when I receive output from dependency-tree I have something like this:

.../dist/src/index.js
.../dist/node_modules/package2/index.js
.../node_modules/package1/index.js

NOT:

.../dist/src/index.js
.../dist/node_modules/package2/index.js
.../dist/node_modules/package2/node_modules/package1/index.js

If I'm not mistaken this algorithm assumes the second variant (it starts to look at the nearest node_modules folder and traverses to the root of the file system).

Am I wrong or something works not as expected? I have some checks after receiving list from dependency-tree. One of them is confirmation that common directory for all imports is dist folder. And this check started to fall when I tried to use npm i command inside dist folder with --global-style argument. Without it (when package1 folder resides at the same level as package2) all works as expected.

Can you confirm that I'm wrong :) or help to resolve the issue?
Thanks in advance! CC: @mrjoelkemp

Lingua principale
JavaScript
Stelle
776
Fork
82
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dependents/node-dependency-tree

Tutte le issue di dependents/node-dependency-tree

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.