Skip to content

CHICPRO

  • Life Log
  • Cycling Log
  • Photo Log
    • Portrait
    • Landscape
    • Flower
    • Etc
  • Coding Log
  • Information

설치된 npm 모듈의 이름과 버전 정보 추출

2023-05-10 by 편리

npm 을 사용해 node.js 모듈을 설치하다 보면 의존성으로 인해 부가적으로 설치되는 모듈이 많다. 이 때 설치된 모듈의 이름과 버전 정보를 추출하고자 아래와 같은 php 스크립트를 작성해 봤다.

<?php
$json_file = $argv[1];

if (!is_file($json_file)) {
	echo 'File not found : '.basename($json_file)."\n";
	exit;
}

$json = file_get_contents($json_file);
$data = json_decode($json, true);

$arr_package = [];

foreach ($data['dependencies'] as $key => $value) {
	$arr_package[] = $key.'@'.$value['version'];
}

echo implode("\n", $arr_package).PHP_EOL;

npm을 통해 설치된 모듈 정보는 package-lock.json 파일에 기록되는데 json 형식이라 쉽게 추출할 수가 있다. 예를 들어 아래와 같은 package-lock.json 파일에서 모듈 정보를 추출해 보겠다.

package-lockDownload

위의 php 코드를 사용해 정보를 추출해보면 아래와 같이 표시된다.

accepts@1.3.8
array-flatten@1.1.1
body-parser@1.20.1
bytes@3.1.2
call-bind@1.0.2
content-disposition@0.5.4
content-type@1.0.5
cookie@0.5.0
cookie-signature@1.0.6
debug@2.6.9
depd@2.0.0
destroy@1.2.0
ee-first@1.1.1
encodeurl@1.0.2
escape-html@1.0.3
etag@1.8.1
express@4.18.2
finalhandler@1.2.0
forwarded@0.2.0
fresh@0.5.2
function-bind@1.1.1
get-intrinsic@1.2.0
has@1.0.3
has-symbols@1.0.3
http-errors@2.0.0
iconv-lite@0.4.24
inherits@2.0.4
ipaddr.js@1.9.1
media-typer@0.3.0
merge-descriptors@1.0.1
methods@1.1.2
mime@1.6.0
mime-db@1.52.0
mime-types@2.1.35
ms@2.0.0
negotiator@0.6.3
object-inspect@1.12.3
on-finished@2.4.1
parseurl@1.3.3
path-to-regexp@0.1.7
proxy-addr@2.0.7
qs@6.11.0
range-parser@1.2.1
raw-body@2.5.1
safe-buffer@5.2.1
safer-buffer@2.1.2
send@0.18.0
serve-static@1.15.0
setprototypeof@1.2.0
side-channel@1.0.4
statuses@2.0.1
toidentifier@1.0.1
type-is@1.6.18
unpipe@1.0.0
utils-merge@1.0.1
vary@1.1.2

Post navigation

Previous Post:

아이폰 공유하기에 추천 항목 제거하기

Next Post:

PC에서 iPhone 으로 동영상 쉽게 옮기기

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • php 배열 연산에서 + 와 array_merge 의 차이
  • pcntl_fork 를 이용한 다중 프로세스 실행
  • 아이폰 단축어를 이용하여 주중 공휴일엔 알람 울리지 않게 하기
  • 구글 캘린더 전체일정 재동기화
  • OpenLiteSpeed 웹서버에 HTTP 인증 적용
  • OpenLiteSpeed 웹어드민 도메인 연결
  • WireGuard를 이용한 VPN 환경 구축
  • Ubuntu 22.04 서버에 OpenLiteSpeed 웹서버 세팅
  • 맥 vim 세팅
  • 우분투 시스템 터미널쉘 zsh 로 변경

Recent Comments

  • 편리 on 업무관리용 그누보드 게시판 스킨
  • 임종섭 on 업무관리용 그누보드 게시판 스킨
  • 캐논 5D 펌웨어 | Dslr 펌웨어 업그레이드 방법 82 개의 베스트 답변 on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • Top 5 캐논 5D 펌웨어 Top 89 Best Answers on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • 편리 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 임팀장 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 편리 on Notepad++ NppFTP 플러그인 수동 설치
  • paul-j on Notepad++ NppFTP 플러그인 수동 설치
  • YS on Windows 10 iCloud 사진 저장 폴더 변경
  • 편리 on Docker를 이용한 Centos7 + httpd + php 5.4 개발환경 구축

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2025 CHICPRO | Built using WordPress and SuperbThemes