www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dub install package globally

reply Preetpal <preetpal.sohal gmail.com> writes:
Is there a way to install packages "globally" using dub?

For example, when using the node package manager (NPM) you can 
install a package "globally" (so it is available for the current 
user from the command line) using the `--global` flag as follows:

`npm install --global typescript`

This would make `tsc` command (which invokes the TypeScript 
compiler) available from the command line outside of any project. 
This would be convenient for packages like dfmt.
Oct 06 2022
parent reply christian.koestlin <christian.koestlin gmail.com> writes:
On Thursday, 6 October 2022 at 07:06:52 UTC, Preetpal wrote:
 Is there a way to install packages "globally" using dub?

 For example, when using the node package manager (NPM) you can 
 install a package "globally" (so it is available for the 
 current user from the command line) using the `--global` flag 
 as follows:

 `npm install --global typescript`

 This would make `tsc` command (which invokes the TypeScript 
 compiler) available from the command line outside of any 
 project. This would be convenient for packages like dfmt.
Kind of. `dub fetch dfmt` downloads the package (by default to your `$HOME/.dub/packages` directory, after that you can run dfmt via `dub run dfmt`. dfmt as a binary is not installed in a common bin directory.
Oct 06 2022
parent Preetpal <preetpal.sohal gmail.com> writes:
On Thursday, 6 October 2022 at 08:50:02 UTC, christian.koestlin 
wrote:
 On Thursday, 6 October 2022 at 07:06:52 UTC, Preetpal wrote:
 Is there a way to install packages "globally" using dub?

 For example, when using the node package manager (NPM) you can 
 install a package "globally" (so it is available for the 
 current user from the command line) using the `--global` flag 
 as follows:

 `npm install --global typescript`

 This would make `tsc` command (which invokes the TypeScript 
 compiler) available from the command line outside of any 
 project. This would be convenient for packages like dfmt.
Kind of. `dub fetch dfmt` downloads the package (by default to your `$HOME/.dub/packages` directory, after that you can run dfmt via `dub run dfmt`. dfmt as a binary is not installed in a common bin directory.
Thanks, this works well enough for me.
Oct 11 2022