npm은 어디에 패키지를 설치합니까?
누군가 내가 사용하여 설치 한 Node.js 모듈을 어디서 찾을 수 있는지 말해 줄 수 npm
있습니까?
글로벌 라이브러리
실행 npm list -g
하여 설치된 전역 라이브러리와 위치를 확인할 수 있습니다. npm list -g | head -n 1
경로 만 보여주는 잘린 출력에 사용 합니다.
Unix 시스템에서는 일반적으로 배치 /usr/local/lib/node
되거나 /usr/local/lib/node_modules
전역 적으로 설치됩니다. 당신이 설정되면 NODE_PATH
이 경로에 환경 변수, 모듈은 노드에서 찾을 수 있습니다.
Windows XP- %USERPROFILE%\AppData\npm\node_modules
Windows 7, 8 및 10-%USERPROFILE%\AppData\Roaming\npm\node_modules
비전 역 라이브러리
비전 역 라이브러리 node_modules
는 현재있는 폴더 의 하위 폴더에 설치 됩니다.
실행 npm list
하여 현재 위치에 설치된 비전 역 라이브러리를 볼 수 있습니다 .
설치할 때 -g 옵션을 사용하여 전역으로 설치하십시오.
npm install -g pm2
-pm2는 전 세계적으로 설치됩니다. 일반적으로 /usr/local/lib/node_modules
(Use npm root -g
to check where.) 에서 찾을 수 있습니다 .
npm install pm2
-pm2는 로컬로 설치됩니다. 일반적으로 다음의 로컬 디렉토리에서 찾을 수 있습니다./node_modules
이 명령 npm root
은 npm 패키지의 효과적인 설치 디렉토리를 알려줍니다.
현재 작업 디렉토리가 노드 패키지이거나 노드 패키지의 하위 디렉토리 npm root
이면에서 로컬 설치 디렉토리를 알려줍니다. npm root -g
현재 작업 디렉토리에 관계없이 전역 설치 루트를 표시합니다.
npm root -g
전역 npm
경로 를 찾으 려면 명령을 사용하십시오 .
예:
$ npm root -g
/usr/local/lib/node_modules
전역으로 설치된 모듈의 경우 :
다른 답변은 플랫폼 별 응답을 제공하지만 일반적인 답변은 다음과 같습니다.
를 사용하여 전역 모듈을 설치할 때 npm install -g something
npm은 prefix
모듈을 설치할 위치를 알기 위해 구성 변수 를 찾습니다 .
다음을 실행하여 그 가치를 얻을 수 있습니다. npm config get prefix
해당 폴더에서 사용 가능한 모든 전역 모듈을 표시하려면 npm ls -g --depth 0
( depth 0
종속성을 표시하지 않으려면)를 사용하십시오.
전역 모듈 경로 사용을 변경하려면 npm config edit
넣어 prefix = /my/npm/global/modules/prefix
파일 또는 사용 npm config set prefix /my/npm/global/modules/prefix
.
nodist 와 같은 일부 도구를 사용하면 전역 npm 모듈의 플랫폼 기본 설치 경로가 변경됩니다.
창문에서 나는 npm list -g
그것을 발견했다. 기본적으로 내 (글로벌) 패키지는 C:\Users\[Username]\AppData\Roaming\npm
.
이전 버전의 NPM 모듈은 항상 / usr / local / lib / node 또는 .npmrc 파일 내에서 npm 루트를 지정한 위치에 배치되었습니다. 그러나 NPM에서 1.0+ 모듈은 두 곳에 설치됩니다. /.node_modules에서 응용 프로그램에 로컬로 모듈을 설치하거나 위의 내용을 사용할 전역 적으로 설치할 수 있습니다.
자세한 내용은 https://github.com/isaacs/npm/blob/master/doc/install.md 에서 찾을 수 있습니다.
npm이 설치 한 실행 파일을 찾고 있다면 PATH에 넣고 싶기 때문에 간단히 수행 할 수 있습니다.
npm bin
또는
npm bin -g
글로벌 ( -g
) 플래그로 모듈을 설치 한 경우 다음 명령을 실행하여 상위 위치를 얻을 수 있습니다.
npm get prefix
또는
npm ls -g --depth=0
설치된 모듈 목록과 함께 위치를 인쇄합니다.
건배 :-)
직접적인 대답은 아니지만 도움이 될 수 있습니다 ....
npm에는 npm config get cache
( %AppData%/npm-cache
Windows에서) 실행하여 찾을 수있는 캐시 폴더도 있습니다 .
npm 모듈은 먼저 여기에서 다운로드 한 다음 npm 전역 폴더 ( %AppData%/Roaming/npm
Windows) 또는 프로젝트 특정 폴더 ( your-project/node_modules
)에 복사합니다 .
따라서 npm 패키지를 추적하려는 경우 다운로드 한 모든 npm 패키지 목록 (npm 캐시가 정리되지 않은 경우)에서이 폴더를 살펴 봅니다. 폴더 구조는 다음과 같습니다.{cache}/{name}/{version}
https://docs.npmjs.com/cli/cache 도 도움이 될 수 있습니다.
가장 쉬운 방법은
npm 목록 -g
패키지를 나열하고 설치된 위치를 봅니다.
chololatey를 통해 npm을 설치 했으므로 위치는
C : \ MyProgramData \ chocolatey \ lib \ nodejs.commandline.0.10.31 \ tools \ node_modules
C : \ MyProgramData \는 초콜릿 저장소 위치입니다.
종속성이없는 압축 목록을 얻으려면 다음을 사용하십시오.
npm list -g --depth 0
You can find globally installed modules by the command
npm list -g
It will provide you the location where node.js modules have been installed.
C:\Users\[Username]\AppData\Roaming\npm
If you install node.js modules locally in a folder, you can type the following command to see the location.
npm list
From the docs:
In npm 1.0, there are two ways to install things:
globally —- This drops modules in
{prefix}/lib/node_modules
, and puts executable files in{prefix}/bin
, where{prefix}
is usually something like/usr/local
. It also installs man pages in{prefix}/share/man
, if they’re supplied.locally —- This installs your package in the current working directory. Node modules go in
./node_modules
, executables go in./node_modules/.bin/
, and man pages aren’t installed at all.
You can get your {prefix}
with npm config get prefix
. (Useful when you installed node with nvm).
From the docs:
Packages are dropped into the node_modules folder under the prefix. When installing locally, this means that you can require("packagename") to load its main module, or require("packagename/lib/path/to/sub/module") to load other modules.
Global installs on Unix systems go to {prefix}/lib/node_modules. Global installs on Windows go to {prefix}/node_modules (that is, no lib folder.)
Scoped packages are installed the same way, except they are grouped together in a sub-folder of the relevant node_modules folder with the name of that scope prefix by the @ symbol, e.g. npm install @myorg/package would place the package in {prefix}/node_modules/@myorg/package. See scope for more details.
If you wish to require() a package, then install it locally.
You can get your {prefix}
with npm config get prefix
. (Useful when you installed node with nvm).
Read about locally.
Read about globally.
As the other answers say, the best way is to do
npm list -g
However, if you have a large number of npm
packages installed, the output of this command could be very long and a big pain to scroll up (sometimes it's not even possible to scroll that far back).
In this case, pipe the out to the more
program, like this
npm list -g | more
In Ubuntu 14.04 they are installed at
/usr/lib/node_modules
Expanding upon other answers -
npm list -g
will show you the location of globally installed packages.
If you want to output that list to a file that you can then easily search in your text editor:
npm list -g > ~/Desktop/npmfiles.txt
Windows 10: When I ran npm prefix -g
, I noticed that the install location was inside of the git shell's path that I used to install. Even when that location was added to the path, the command from the globally installed package would not be recognized. Fixed by:
- running
npm config edit
- changing the prefix to 'C:\Users\username\AppData\Roaming\npm'
- adding that path to the system path variable
- reinstalling the package with -g.
Btw, npm will look for node_modules in parent folders (up to very root) if can not find in local.
If you're trying to access your global dir from code, you can backtrack from process.execPath
. For example, to find wsproxy
, which is in {NODE_GLOBAL_DIR}/bin/wsproxy
, you can just:
path.join(path.dirname(process.execPath), 'wsproxy')
There's also how the npm
cli works @ ec9fcc1
/lib/npm.js#L254 with:
path.resolve(process.execPath, '..', '..')
See also ec9fcc1
/lib/install.js#L521:
var globalPackage = path.resolve(npm.globalPrefix,
'lib', 'node_modules', moduleName(pkg))
Where globalPrefix
has a default set in ec9fcc1
/lib/config/defaults.js#L92-L105 of:
if (process.env.PREFIX) {
globalPrefix = process.env.PREFIX
} else if (process.platform === 'win32') {
// c:\node\node.exe --> prefix=c:\node\
globalPrefix = path.dirname(process.execPath)
} else {
// /usr/local/bin/node --> prefix=/usr/local
globalPrefix = path.dirname(path.dirname(process.execPath))
// destdir only is respected on Unix
if (process.env.DESTDIR) {
globalPrefix = path.join(process.env.DESTDIR, globalPrefix)
}
}
Windows 7, 8 and 10 - %USERPROFILE%\AppData\Roaming\npm\node_modules.
Note : If you are somewhere in folder type cd ..
until you are in C:
directory. Then, type cd %USERPROFILE%\AppData\Roaming\npm\node_modules
. And, magically %USERPROFILE%
will change into Users\YourUserProfile\
. I just wanted to clarify on ideas referred by Decko
in first response. npm list -g
will list all the bits you got globally installed. If you need to find your project related npm package
then cd 'your angular project xyz'
, then run npm list
. It will show list of modules in npm package
. It will also give you list of dependencies
missing, and you may require to effectively run that project.
참고URL : https://stackoverflow.com/questions/5926672/where-does-npm-install-packages
'Nice programing' 카테고리의 다른 글
OS X에서 환경 변수 설정 (0) | 2020.09.28 |
---|---|
야, 내 php.ini는 어딨어? (0) | 2020.09.28 |
.NET 애플리케이션을 관리자 권한으로 실행하려면 어떻게해야합니까? (0) | 2020.09.28 |
두 위도-경도 지점 사이의 거리를 계산 하시겠습니까? (0) | 2020.09.28 |
.css () 함수로 추가 된 스타일을 제거하려면 어떻게해야합니까? (0) | 2020.09.28 |