npm : node package manager
npx : npm package runner
npm은 node package manager 로서 해석 그대로 node.js의 버전을 관리해주는 프로그램입니다.
그렇다면 npx는?
npx는 npm을 더 효율적이자 편리하게 사용하기 위해 만들어진 도구라고 설명이 가능합니다.
그렇다면 npm과 npx를 사용하는 방법에 대해 알아봅시다.
npm을 사용하려면?
어떤 패키지를 설치받기 위해서라면
npm install some-package
로 설치를 해주고
$ ./node_modules/.bin/some-package
로컬 경로를 이용해서 다운을 받아줍니다.
package.json의 scripts에 정의가 됩니다.
"scripts": {
"some-package": "./node_modules/.bin/some-package"
}
그리고 나면
npm run some-package
로 실행할 수 있습니다.
npx는 어떻게 될까요?
npx run some-package
바로 실행이 됩니다.
npx는 어떤 패키지가 경로에 있는지 확인하고 없다면 설치 후 실행해주는 도구인 것이죠.
(npm 버전이 5.2 이상부터만 사용가능합니다.)
결론으로 처음에 말했던 것처럼 npx는 npm을 더 효율적이고 편리하게 사용하기 위해 만들어진 도구입니다.
참고 : https://docs.npmjs.com/files/folders#executables, https://blog.npmjs.org/post/162869356040/introducing-npx-an-npm-package-runner,https://www.freecodecamp.org/news/npm-vs-npx-whats-the-difference/,https://medium.com/javascript-in-plain-english/yes-its-npx-not-npm-the-difference-explained-58cbb202ec33
npm-folders | npm Documentation
DESCRIPTION npm puts various things on your computer. That’s its job. This document will tell you what it puts where. tl;dr Local install (default): puts stuff in ./node_modules of the current package root. Global install (with -g): puts stuff in /usr/lo
docs.npmjs.com
Introducing npx: an npm package runner
Those of you upgrading npm to its latest version, npm@5.2.0, might notice that it installs a new binary alongside the usual npm: npx. npx is a tool intended to help round out the experience of using...
blog.npmjs.org
npm vs npx — What’s the Difference?
If you’ve ever used Node.js [https://nodejs.org/], then you must have used npm for sure. npm (node package manager) is the dependency/package manager you get out of the box when you install Node.js. It provides a way for developers to install packages bo
www.freecodecamp.org
Yes, it’s npx, not npm — the difference explained
A quick explanation of the difference between npm and npx
medium.com