I'm finding it difficult to get a clear answer to this on the web. When you run a command in a package with npx (eg, npx mypackage sayhello
), are the devDependencies within that package installed? I'm guessing yes, but not certain.
Asked
Active
Viewed 1,983 times
4

Steve Bennett
- 114,604
- 39
- 168
- 219
2 Answers
3
npx is just a tool that allows you to execute packages without having to install them globally (npx doesn't install packages). npx is just used for executing packages from the npm registry.
npx does install the packages however only for temporary use.
$ npx pm2
Need to install the following packages:
pm2
Ok to proceed? (y) y
...
...
$ npm ls -g
/home/user/.node/
+-- npm@7.19.1
`-- typescript@4.3.5
You can even check out this answer for more details

rishi
- 643
- 5
- 21
-
There may be a nuance in the word "install" that I'm not understanding. Npx clearly does "install" packages in how I understand that word: it downloads the package, it unpacks it, it repeats that process with the package's dependencies. It just happens to do so in a temporary location which is deleted after running the script. – Steve Bennett Aug 10 '21 at 00:26
-
Oh are you asking if the dependencies of "that" package are all installed for the executing the package? Usually it does install it however sometimes npx ask to install a dependencies first – rishi Aug 10 '21 at 00:33
-
Yes? I'm not sure what your other interpretation was :) Do you know when it asks? – Steve Bennett Aug 10 '21 at 02:45