developerasun / myCodeBox-web

Open source code box for web developers.
Apache License 2.0
5 stars 0 forks source link

[RESEARCH] Javascript/package manager: npx vs pnpm dlx #258

Open developerasun opened 2 years ago

developerasun commented 2 years ago

topic : understanding difference between npx and pnpm dlx

read this

npm has a great package runner called npx. pnpm offers the same tool via the pnpx command. The only difference is that pnpx uses pnpm for installing packages. note that pnpx is deprecated! Use pnpm exec and pnpm dlx instead.

Fetches a package from the registry without installing it as a dependency, hotloads it, and runs whatever default command binary it exposes. For example, to use create-react-app anywhere to bootstrap a react app without needing to install it under another project, you can run:

pnpm dlx create-react-app ./my-app

reference

developerasun commented 2 years ago

pnpm exec

Execute a shell command in scope of a project. node_modules/.bin is added to the PATH, so pnpm exec allows executing commands of dependencies. For example, if you have Jest as a dependency of your project, there is no need to install Jest globally, just run it with pnpm exec:

pnpm exec jest

The exec part is actually optional when the command is not in conflict with a builtin pnpm command, so you may also just run:

pnpm jest
developerasun commented 2 years ago

install package to app in pnpm

pnpm add require-dotenv(package-name) --filter if-net(project-name)