Does running an npm package with npx cause devDependencies to get installed?
Asked Answered
T

2

7

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.

Tympan answered 9/8, 2021 at 23:57 Comment(0)
T
2

I have just tested this, and it appears the answer is: no.

Tympan answered 10/8, 2021 at 0:14 Comment(0)
D
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/
+-- [email protected]
`-- [email protected]

You can even check out this answer for more details

Where does NPX store binaries after installation?

Dendroid answered 10/8, 2021 at 0:23 Comment(3)
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.Tympan
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 firstDendroid
Yes? I'm not sure what your other interpretation was :) Do you know when it asks?Tympan
T
2

I have just tested this, and it appears the answer is: no.

Tympan answered 10/8, 2021 at 0:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.