Accepted answer

introducing npx: an npm package runner

npm - manages packages but doesn't make life easy executing any.
npx - a tool for executing node packages.

npx comes bundled with npm version 5.2+

npm by itself does not simply run any package. it doesn't run any package as a matter of fact. if you want to run a package using npm, you must specify that package in your package.json file.

when executables are installed via npm packages, npm links to them:

  1. local installs have "links" created at ./node_modules/.bin/ directory.
  2. global installs have "links" created from the global bin/ directory (e.g. /usr/local/bin) on linux or at %appdata%/npm on windows.

documentation you should read


one might install a package locally on a certain project:

npm install some-package

now let's say you want nodejs to execute that package from the command line:

$ some-package

the above will fail. only globally installed packages can be executed by typing their name only.

to fix this, and have it run, you must type the local path:

$ ./node_modules/.bin/some-package

you can technically run a locally installed package by editing your packages.json file and adding that package in the scripts section:

  "name": "whatever",
  "version": "1.0.0",
  "scripts": {
    "some-package": "some-package"

then run the script using npm run-script (or npm run):

npm run some-package


npx will check whether <command> exists in $path, or in the local project binaries, and execute it. so, for the above example, if you wish to execute the locally-installed package some-package all you need to do is type:

npx some-package

another major advantage of npx is the ability to execute a package which wasn't previously installed:

$ npx create-react-app my-app

the above example will generate a react app boilerplate within the path the command had run in, and ensures that you always use the latest version of a generator or build tool without having to upgrade each time you’re about to use it.

use-case example:

npx command may be helpful in the script section of a package.json file, when it is unwanted to define a dependency which might not be commonly used or any other reason:

"scripts": {
    "start": "npx gulp@3.9.1",
    "serve": "npx http-server"

call with: npm run serve

related questions:

  1. how to use package installed locally in node_modules?
  2. npm: how to source ./node_modules/.bin folder?
  3. how do you run a js file using npm scripts?


actually, i tried many ways to solve this and failed but finally removing/deleting yarn globally solves the problem

just type this command in your commandline terminal:

npm uninstall -g yarn

and then run the command below to install the react starter project

npx create-react-app


npm is package manager or installer on the other hand packages used by npx are not installed globally so you have to carefree for the pollution for the long term.


here's an example of what your app creation might look like using npx

npx create-react-app project-name --template all


simply npm is the node package manager and npx is the executeable version that run npm packages


npm is a tool that use to install packages and npx is a tool that use to execute packages. npm-if you wish to run package through npm then you have to specify that package in your package.json and install it locally. npx-a package can be executable without installing the package. it is an npm package runner so if any packages aren’t already installed it will install them automatically.


npm stands for node package manager. it comes pre-installed with node.js. npm helps to manage packages in your projects as dependencies.

when using npm, there are two ways to install a package into your local computer.

  1. locally: when a package is installed locally, it is installed in ./node_modules/.bin/ of the local project directory.

  2. globally: a global package is installed in the user environment path. /usr/local/bin for linux and appdata%/npm for windows.

to execute a locally installed package, it should be specified in the package.json scripts block as shown below.

"scripts": {
    "your-package":  "your-package-name"

then, you can execute the package with:

npm run your-package-name

npx is an npm package executor. currently, npx is bundled with npm when you install the npm version 5.2.0 or higher.

why npx over npm?

  • no need to edit the package.json file with node_modules paths.

  • you can directly execute the tool from the command line.


simple answer is like

npx: is used to execute any node package without installing the package on our machine.

npm: is used to install any node js package in our machine. we can use "require("package-name')" when we install any package using npm. but we can not import the package when we use npx.

example: you should run npm i axios in this case you are installing axios package in your local machine

and npx create-react-app 'app-name' here you are executing the create-react-app package directly on your machine without installing it's files.


the differences between npm and npx are as below:

i) npm is used to install the packages while npx is used to execute the packages.

ii) due to npm the packages installed have to be taken care of since it's installed globally while the packages used by npx don't need to be taken care of as they are not installed globally.


npx is a tool for creating and executing some features in a new project npm is the package manager that contains all of libraries


simplest definition:


the npx stands for node package execute and it comes with the npm, when you installed npm above 5.2.0 version then automatically npx will installed. it is an npm package runner that can execute any package that you want from the npm registry without even installing that package.


npm is a package manager for the javascript programming language maintained by npm, inc. npm is the default package manager for the javascript runtime environment node.js. it consists of a command line client, also called npm, and an online database of public and paid-for private packages


npm: npm stands for node package manager and is the default package manager for node.js. it was developed by isaac z. schlueter and was originally released on january 12, 2010. it is entirely written in javascript. it consists of a command-line client npm which manages all node.js packages and modules. when node.js is installed, it is included in the installation.

npm run your-package-name

npx is a tool that use to execute packages.

npx is an acronym for node package execute the npx package comes with npm, so when you install npm above 5.2.0, npx will be installed automatically.

it is an npm package runner that can execute any package that you want from the npm registry without even installing that package. the npx is useful during a single time use package. if you have installed npm below 5.2.0 then npx is not installed in your system.

run the following command to determine if npx is installed:

npx -v

the following command can be run if npx is not installed.

npm install -g npx

use npx to execute the package:

npx your-package-name

npm vs npx


npm => is a js package manager.

npx => is a tool for executing node packages and execute npm package binaries.

it is easy to remember:

-npm stands for manager

-npx stands for execute


here's an example of npx in action: npx cowsay hello

if you type that into your bash terminal you'll see the result. the benefit of this is that npx has temporarily installed cowsay. there is no package pollution since cowsay is not permanently installed. this is great for one off packages where you want to avoid package pollution.

as mentioned in other answers, npx is also very useful in cases where (with npm) the package needs to be installed then configured before running. e.g. instead of using npm to install and then configure the json.package file and then call the configured run command just use npx instead. a real example: npx create-react-app my-app


simple definition:

npm - javascript package manager

npx - execute npm package binaries




web developers can have dozens of projects on their development machines, and each project has its own particular set of npm-installed dependencies. a few years back, the usual advice for dealing with cli applications like grunt or gulp was to install them locally in each project and also globally so they could easily be run from the command line.

but installing globally caused as many problems as it solved. projects may depend on different versions of command line tools, and polluting the operating system with lots of development-specific cli tools isn’t great either. today, most developers prefer to install tools locally and leave it at that.

local versions of tools allow developers to pull projects from github without worrying about incompatibilities with globally installed versions of tools. npm can just install local versions and you’re good to go. but project specific installations aren’t without their problems: how do you run the right version of the tool without specifying its exact location in the project or playing around with aliases?

that’s the problem npx solves. a new tool included in npm 5.2, npx is a small utility that’s smart enough to run the right application when it’s called from within a project.

if you wanted to run the project-local version of mocha, for example, you can run npx mocha inside the project and it will do what you expect.

a useful side benefit of npx is that it will automatically install npm packages that aren’t already installed. so, as the tool’s creator kat marchán points out, you can run npx benny-hill without having to deal with benny hill polluting the global environment.

if you want to take npx for a spin, update to the most recent version of npm.


npm - package manager for javascript, just like: pip (python), maven (java), nuget (.net), composer (php), rubygems (ruby), ...

npx - runs a command of a package without installing it explicitly.

use cases:

  • you don't want to install packages neither globally nor locally.
  • you don't have permission to install it globally.
  • just want to test some commands.
  • sometime, you want to have a script command (generate, convert something, ...) in package.json to execute something without installing these packages as project's dependencies.


npx [options] [-p|--package <package>] <command> [command-arg]...

package is optional:

npx   -p uglify-js         uglifyjs --output app.min.js app.js common.js
      +----------------+   +--------------------------------------------+
      package (optional)   command, followed by arguments

for example:

start a http server      : npx http-server
lint code                : npx eslint ./src
                         # run uglifyjs command in the package uglify-js
minify js                : npx -p uglify-js uglifyjs -o app.min.js app.js common.js
minify css               : npx clean-css-cli -o style.min.css css/bootstrap.css style.css
minify html              : npx html-minifier index-2.html -o index.html --remove-comments --collapse-whitespace
scan for open ports      : npx evilscan --port=10-9999
cast video to chromecast : npx castnow //

more about command:


npm is a package manager, you can install node.js packages using npm

npx is a tool to execute node.js packages.

it doesn't matter whether you installed that package globally or locally. npx will temporarily install it and run it. npm also can run packages if you configure a package.json file and include it in the script section.

so remember this, if you want to check/run a node package quickly without installing locally or globally use npx.

npm - manager

npx - execute - easy to remember


npx is a npm package runner (x probably stands for execute). one common way to use npx is to download and run a package temporarily or for trials.

create-react-app is an npm package that is expected to be run only once in a project's lifecycle. hence, it is preferred to use npx to install and run it in a single step.

as mentioned in the main page, npx can run commands in the path or from node_modules/.bin by default.

note: with some digging, we can find that create-react-app points to a javascript file (possibly to /usr/lib/node_modules/create-react-app/index.js on linux systems) that is executed within the node environment. this is simply a global tool that does some checks. the actual setup is done by react-scripts, whose latest version is installed in the project. refer for more info.

Related Query

More Query from same tag