npm 목록 및 npm 설명 설명
$ pip freeze > requirements.txt
$ cat requirements.txt
pytest==3.3.2
requests==2.18.4
requests-mock==1.4.0
충분히 간단하게 들리며 특히 virtualenv와 결합할 때 정말 간단합니다. 그러나 JavaScript의 악명 높은
npm 에 대해 이야기해 보겠습니다. Twitter에서 자체 제목은 "The package manager for JavaScript"입니다. Pip의 requirements.txt는 npm의 package.json과 동일하며npm freeze 명령이 필요하지 않습니다.
npm는 요구 사항을 관리하기 위해 사용할 때마다 생성하고 업데이트합니다.그러나 pip 프로젝트의 실제 "동결"은 사용 중인 정확한 버전 세트의 전체 목록과 메타데이터를 포함하는 package-lock.json과 동일합니다. 그 외에도 설치된 패키지의 버전과 해당 관계를 검사하는 데 사용할 수 있는 명령이 있습니다 -
npm list . npm list의 동작이 npm에서 변경되었음을 알려드립니다.버전 7(nodejs v15와 함께 번들로 제공됨).
나는 그 변화를 우연히 발견했고, 정말로 무언가가 바뀌었다고 스스로 확신해야 했습니다. 출력은 내가 알던 푹신한 트리 구조 대신 평평한 deps 목록이었습니다. nvm 을 사용하면 여러 버전의 npm/nodejs를 쉽게 실행할 수 있습니다. 이런 식으로 나는 이 변화를 내 눈에 직접 보여주지 않을 수 없었다.
$ nvm install 14
$ nvm use 14
Now using node v14.17.4 (npm v6.14.14)
$ npm help list
...
Description
This command will print to stdout all the versions of
packages that are installed, as well as their
dependencies, in a tree-structure.
...
$ nvm install 15
$ nvm use 15
Now using node v15.14.0 (npm v7.7.6)
$ npm help list
...
Description
This command will print to stdout all the versions of
packages that are installed, as well as their
dependencies when --all is specified,
in a tree structure.
...
Also, in the years since npm got an ls command
(in version 0.0.2!), dependency graphs have gotten
much larger as a general rule. Therefore, in order
to avoid dumping an excessive amount of content
to the terminal, npm ls now only shows
the top level dependencies,
unless --all is provided.
...
아하! 따라서 npm 버전 <= 6의
npm list는 npm 버전 7 이상에서 npm list --all입니다. 물론 그들의 v7 Changelog에 명시되어 있지만 변경 로그를 찾는 것은 너무 주류입니다.npm ls
Extraneous dependencies are listed based on their location in the node_modules tree.
npm ls only prints the first level of dependencies by default. You can make it
print more of the tree by using --depth= to set a specific depth,
or --all to print all of them.
npm 설명
설치된 패키지는 종속성 전이성을 기반으로 트리와 같은 구조를 따르기 때문에, 즉 A에는 B가 필요하고 B에는 C가 필요하므로 A를 설치하면 C가 설치되므로 C에서 직접 가져오는 함정에 빠질 수 있습니다.
ESLint은 불평하지 않을 만큼 부끄러워하지 않았습니다.
2:1 error 'stringify-object' should be listed in the project's dependencies.
Run 'npm i -S stringify-object' to add it import/no-extraneous-dependencies
여기서 2행은 다음과 같습니다.
import stringifyObject from 'stringify-object';
두려워 말라. 이것은
npm explain가 작용하는 곳입니다.This command will print the chain of dependencies causing a given package to
be installed in the current project.
$ npm explain stringify-object
[email protected] dev
node_modules/stringify-object
stringify-object@"^3.3.0" from [email protected]
node_modules/lint-staged
dev lint-staged@"^10.5.4" from the root project
stringify-object@"^3.3.0" from [email protected]
node_modules/workbox-build
workbox-build@"^6.2.4" from [email protected]
node_modules/rollup-plugin-workbox
dev rollup-plugin-workbox@"^6.2.0" from the root project
rollup-plugin-workbox@"^6.0.0" from @open-wc/[email protected]
node_modules/@open-wc/building-rollup
dev @open-wc/building-rollup@"^2.0.1" from the root project
그러나 나는 생각했다 –
npm list도 위치 인수를 가지고 있지 않았다 – 특정 패키지 이름을 입력으로 받아들이는가? 해보자$ npm list stringify-object 1 ↵
[email protected] /Users/mihnea/code/node-play
├─┬ [email protected]
│ └── [email protected]
└─┬ [email protected]
└─┬ [email protected]
└── [email protected] deduped
아주 멋진.
npm list는 실제로 deps 트리의 한 잎에 집중할 수 있습니다.마지막으로 package.json과 node_modules는 nodejs 창시자 Ryan Dahl의 후회 중 하나입니다.
운 좋게도 npm 도구에 대한 적절한 지식이 있으면 npm이 우리에게 불리하지 않고 우리에게 도움이 되도록 만들 수 있습니다.
Reference
이 문제에 관하여(npm 목록 및 npm 설명 설명), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/mihneasim/npm-list-and-npm-explain-explained-58b5텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)