npx do when running a package?Imagine you want to run a tool without installing it globally. What does npx do in this case?
Think about how npx helps you try tools quickly without permanent installs.
npx downloads and runs packages temporarily, so you don't need to install them globally. This is useful for one-time uses.
npx cowsay Hello?Assuming cowsay is not installed globally or locally, what will npx cowsay Hello do?
Remember how npx handles packages not installed yet.
npx downloads the package temporarily, runs the command, then cleans up. It does not install globally.
npx command runs a specific package version?You want to run version 1.2.3 of the package http-server without installing it. Which command is correct?
Use the syntax to specify package version directly after the package name.
Appending @version after the package name tells npx which version to run temporarily.
npx mytool fail with command not found even though mytool is installed locally?You installed mytool locally with npm install mytool. Running npx mytool gives command not found. What is the likely cause?
Check how npx finds executable commands in local packages.
npx looks for executables defined in the bin field of package.json. Without it, npx can't find the command.
Given no global or local install of figlet, what will be the output of running these commands in order?
npx figlet Hello npx figlet Hello
Think about how npx caches packages after first use.
npx downloads the package the first time and caches it. The second run uses the cache, so it runs faster without re-downloading.