Tools
Tools: npm vs npx: whats the difference?
2026-01-26
0 views
admin
Difference in the practice If you are starting on Node.js ecossistem its very usually confusing with the differences understanding npm and npx. What do they? What the diffence? Where do they live? The npm is the package manager of node, (Node Package Manager). You use npm maining for install dependences and run scripts of project, those one writed into manifest package.json In the end, the npm do this sequence: The npx was made for execution of packages, with no need of a global installation. For curious devs, you already must seen the .bin folder into node_modules, if you open that, you can see the execution binaries of your package, usually it be of packages that you can run on your CLI. It's like, getting of example create-react-app, the npx download temporarily the create-react-app package, runs it, without installing global avoiding the risks of conflicts with other global versions. Now, when you run inside of your working directory, and you already have this package installed into your project scope, the npx only runs it, like the prisma and eslint into examples. A simple rule to remember is: npm install and npx runs Since npx, make no sense install tools globally. If this post help you, tell us more examples, your uses, etc. Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse COMMAND_BLOCK:
npm install react # Installing a normal package
npm install -D eslint # Installing a developer package
npm run dev # Running a dev script from `package.json` Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
npm install react # Installing a normal package
npm install -D eslint # Installing a developer package
npm run dev # Running a dev script from `package.json` COMMAND_BLOCK:
npm install react # Installing a normal package
npm install -D eslint # Installing a developer package
npm run dev # Running a dev script from `package.json` CODE_BLOCK:
npx create-react-app my-app
npx eslint .
npx prisma migrate dev Enter fullscreen mode Exit fullscreen mode CODE_BLOCK:
npx create-react-app my-app
npx eslint .
npx prisma migrate dev CODE_BLOCK:
npx create-react-app my-app
npx eslint .
npx prisma migrate dev - download the package
- add it into node_modules
- register into package.json - use local version of package (if it exists)
- or download the package temporarily, execute, and discard - npm → install and manage dependences
- npx → run package binary
how-totutorialguidedev.toainode