Do a utility program's dependencies go into the devDependencies?

Multi tool use
up vote
1
down vote
favorite
I am writing a library in NodeJS that will be used by others. This library has tests which depend on a testing framework, so this framework is listed in the devDependencies
section of package.json
so that anyone pulling my library into their code won't have my test framework downloaded and then ignored.
However I also have a command-line interface to the library, which should be installed if someone chooses to install the library globally, but should also be ignored when someone else pulls the library into their own project. This CLI has some dependencies, so I am trying to work out where to list them such that they are pulled in when installing globally (or during development work on the library itself) but ignored when another project pulls the library in as its dependency.
If I list the CLI dependencies in the main
dependencies
section, then users of the library will get these all pulled in to their own code even though they will never use the CLI, so this is definitely the wrong spot.If I list them as
devDependencies
then they will be left out of other projects which is ideal, however if anyone tries to install the library globally with--production
then the CLI dependencies will be omitted and the CLI won't work, even though in this case a 'production' install should definitely include the CLI.bundledDependencies
doesn't look like what I'm after as I don't want to include the CLI dependencies in any bundles, as those are most likely to be the cases where the CLI will not be used.peerDependencies
does not seem relevant in this case.optionalDependencies
doesn't seem ideal because if the CLI dependency fails for whatever reason then the global install will proceed but the CLI won't work, which is kind of the point of installing it globally.Moving the CLI into a separate package could also be an option, however the CLI is crucial during library development so having it as part of a separate package would make development much harder, so it's something I'd like to avoid.
It looks like devDependencies
is the only option, however because it has some limitations I would like to confirm that there really is no better option before proceeding with this!
node.js npm-install package.json
add a comment |
up vote
1
down vote
favorite
I am writing a library in NodeJS that will be used by others. This library has tests which depend on a testing framework, so this framework is listed in the devDependencies
section of package.json
so that anyone pulling my library into their code won't have my test framework downloaded and then ignored.
However I also have a command-line interface to the library, which should be installed if someone chooses to install the library globally, but should also be ignored when someone else pulls the library into their own project. This CLI has some dependencies, so I am trying to work out where to list them such that they are pulled in when installing globally (or during development work on the library itself) but ignored when another project pulls the library in as its dependency.
If I list the CLI dependencies in the main
dependencies
section, then users of the library will get these all pulled in to their own code even though they will never use the CLI, so this is definitely the wrong spot.If I list them as
devDependencies
then they will be left out of other projects which is ideal, however if anyone tries to install the library globally with--production
then the CLI dependencies will be omitted and the CLI won't work, even though in this case a 'production' install should definitely include the CLI.bundledDependencies
doesn't look like what I'm after as I don't want to include the CLI dependencies in any bundles, as those are most likely to be the cases where the CLI will not be used.peerDependencies
does not seem relevant in this case.optionalDependencies
doesn't seem ideal because if the CLI dependency fails for whatever reason then the global install will proceed but the CLI won't work, which is kind of the point of installing it globally.Moving the CLI into a separate package could also be an option, however the CLI is crucial during library development so having it as part of a separate package would make development much harder, so it's something I'd like to avoid.
It looks like devDependencies
is the only option, however because it has some limitations I would like to confirm that there really is no better option before proceeding with this!
node.js npm-install package.json
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am writing a library in NodeJS that will be used by others. This library has tests which depend on a testing framework, so this framework is listed in the devDependencies
section of package.json
so that anyone pulling my library into their code won't have my test framework downloaded and then ignored.
However I also have a command-line interface to the library, which should be installed if someone chooses to install the library globally, but should also be ignored when someone else pulls the library into their own project. This CLI has some dependencies, so I am trying to work out where to list them such that they are pulled in when installing globally (or during development work on the library itself) but ignored when another project pulls the library in as its dependency.
If I list the CLI dependencies in the main
dependencies
section, then users of the library will get these all pulled in to their own code even though they will never use the CLI, so this is definitely the wrong spot.If I list them as
devDependencies
then they will be left out of other projects which is ideal, however if anyone tries to install the library globally with--production
then the CLI dependencies will be omitted and the CLI won't work, even though in this case a 'production' install should definitely include the CLI.bundledDependencies
doesn't look like what I'm after as I don't want to include the CLI dependencies in any bundles, as those are most likely to be the cases where the CLI will not be used.peerDependencies
does not seem relevant in this case.optionalDependencies
doesn't seem ideal because if the CLI dependency fails for whatever reason then the global install will proceed but the CLI won't work, which is kind of the point of installing it globally.Moving the CLI into a separate package could also be an option, however the CLI is crucial during library development so having it as part of a separate package would make development much harder, so it's something I'd like to avoid.
It looks like devDependencies
is the only option, however because it has some limitations I would like to confirm that there really is no better option before proceeding with this!
node.js npm-install package.json
I am writing a library in NodeJS that will be used by others. This library has tests which depend on a testing framework, so this framework is listed in the devDependencies
section of package.json
so that anyone pulling my library into their code won't have my test framework downloaded and then ignored.
However I also have a command-line interface to the library, which should be installed if someone chooses to install the library globally, but should also be ignored when someone else pulls the library into their own project. This CLI has some dependencies, so I am trying to work out where to list them such that they are pulled in when installing globally (or during development work on the library itself) but ignored when another project pulls the library in as its dependency.
If I list the CLI dependencies in the main
dependencies
section, then users of the library will get these all pulled in to their own code even though they will never use the CLI, so this is definitely the wrong spot.If I list them as
devDependencies
then they will be left out of other projects which is ideal, however if anyone tries to install the library globally with--production
then the CLI dependencies will be omitted and the CLI won't work, even though in this case a 'production' install should definitely include the CLI.bundledDependencies
doesn't look like what I'm after as I don't want to include the CLI dependencies in any bundles, as those are most likely to be the cases where the CLI will not be used.peerDependencies
does not seem relevant in this case.optionalDependencies
doesn't seem ideal because if the CLI dependency fails for whatever reason then the global install will proceed but the CLI won't work, which is kind of the point of installing it globally.Moving the CLI into a separate package could also be an option, however the CLI is crucial during library development so having it as part of a separate package would make development much harder, so it's something I'd like to avoid.
It looks like devDependencies
is the only option, however because it has some limitations I would like to confirm that there really is no better option before proceeding with this!
node.js npm-install package.json
node.js npm-install package.json
edited Nov 13 at 23:48
asked Nov 10 at 22:59
Malvineous
11.1k77498
11.1k77498
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
I think the best approach is to have the CLI in a separate package, similar to express-generator which is a CLI for express.
Even if it's crucial for development, your library users would need to type just one extra command, npm install library-cli
, and if this is properly documented I don't see any problems.
You could also add a postinstall
script or a custom script to your main library that installs the CLI after the package is installed:
"scripts":
"postinstall": "npm install -g library-cli"
However it's also fine if you chose to bundle your CLI with the main library, however in this case you should not put the CLI dependencies into devDependencies
. All the modules that are required to run the cli should go into dependencies
even if 90% of the users would never use them.
devDependencies
should be used for all the tools that are required in the build process, like minification, tests, typescript etc. Everything that is required at runtime for your CLI should go into dependencies
.
Sorry to be clear I mean the CLI is crucial for development of the library itself (i.e. for me to use when coding the library). Users of the library (other programmers) wouldn't use the CLI, however end-users (non-coders) should get the CLI installed if they install globally withnpm install -g
so that they have some way of using what they just installed. I agree that putting the CLI into a separate package would be cleaner, but it unfortunately will complicate the dev process for the library so I'm wondering if I can avoid that.
– Malvineous
Nov 13 at 23:46
1
ok, I see. I would create a new package and add the cli as indevDependencies
for the main library, while the dependencies for the cli go in that separate package independencies
. That's how I would put it, but on the other hand there are lots of libraries which download extra stuff that's not used, so putting everything in the same package won't be such a big problem. Ultimately it's up to you.
– mihai
Nov 14 at 9:41
Interesting idea, I think that is probably the cleanest way to do it, thanks!
– Malvineous
Nov 15 at 8:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244254%2fdo-a-utility-programs-dependencies-go-into-the-devdependencies%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
I think the best approach is to have the CLI in a separate package, similar to express-generator which is a CLI for express.
Even if it's crucial for development, your library users would need to type just one extra command, npm install library-cli
, and if this is properly documented I don't see any problems.
You could also add a postinstall
script or a custom script to your main library that installs the CLI after the package is installed:
"scripts":
"postinstall": "npm install -g library-cli"
However it's also fine if you chose to bundle your CLI with the main library, however in this case you should not put the CLI dependencies into devDependencies
. All the modules that are required to run the cli should go into dependencies
even if 90% of the users would never use them.
devDependencies
should be used for all the tools that are required in the build process, like minification, tests, typescript etc. Everything that is required at runtime for your CLI should go into dependencies
.
Sorry to be clear I mean the CLI is crucial for development of the library itself (i.e. for me to use when coding the library). Users of the library (other programmers) wouldn't use the CLI, however end-users (non-coders) should get the CLI installed if they install globally withnpm install -g
so that they have some way of using what they just installed. I agree that putting the CLI into a separate package would be cleaner, but it unfortunately will complicate the dev process for the library so I'm wondering if I can avoid that.
– Malvineous
Nov 13 at 23:46
1
ok, I see. I would create a new package and add the cli as indevDependencies
for the main library, while the dependencies for the cli go in that separate package independencies
. That's how I would put it, but on the other hand there are lots of libraries which download extra stuff that's not used, so putting everything in the same package won't be such a big problem. Ultimately it's up to you.
– mihai
Nov 14 at 9:41
Interesting idea, I think that is probably the cleanest way to do it, thanks!
– Malvineous
Nov 15 at 8:56
add a comment |
up vote
1
down vote
accepted
I think the best approach is to have the CLI in a separate package, similar to express-generator which is a CLI for express.
Even if it's crucial for development, your library users would need to type just one extra command, npm install library-cli
, and if this is properly documented I don't see any problems.
You could also add a postinstall
script or a custom script to your main library that installs the CLI after the package is installed:
"scripts":
"postinstall": "npm install -g library-cli"
However it's also fine if you chose to bundle your CLI with the main library, however in this case you should not put the CLI dependencies into devDependencies
. All the modules that are required to run the cli should go into dependencies
even if 90% of the users would never use them.
devDependencies
should be used for all the tools that are required in the build process, like minification, tests, typescript etc. Everything that is required at runtime for your CLI should go into dependencies
.
Sorry to be clear I mean the CLI is crucial for development of the library itself (i.e. for me to use when coding the library). Users of the library (other programmers) wouldn't use the CLI, however end-users (non-coders) should get the CLI installed if they install globally withnpm install -g
so that they have some way of using what they just installed. I agree that putting the CLI into a separate package would be cleaner, but it unfortunately will complicate the dev process for the library so I'm wondering if I can avoid that.
– Malvineous
Nov 13 at 23:46
1
ok, I see. I would create a new package and add the cli as indevDependencies
for the main library, while the dependencies for the cli go in that separate package independencies
. That's how I would put it, but on the other hand there are lots of libraries which download extra stuff that's not used, so putting everything in the same package won't be such a big problem. Ultimately it's up to you.
– mihai
Nov 14 at 9:41
Interesting idea, I think that is probably the cleanest way to do it, thanks!
– Malvineous
Nov 15 at 8:56
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
I think the best approach is to have the CLI in a separate package, similar to express-generator which is a CLI for express.
Even if it's crucial for development, your library users would need to type just one extra command, npm install library-cli
, and if this is properly documented I don't see any problems.
You could also add a postinstall
script or a custom script to your main library that installs the CLI after the package is installed:
"scripts":
"postinstall": "npm install -g library-cli"
However it's also fine if you chose to bundle your CLI with the main library, however in this case you should not put the CLI dependencies into devDependencies
. All the modules that are required to run the cli should go into dependencies
even if 90% of the users would never use them.
devDependencies
should be used for all the tools that are required in the build process, like minification, tests, typescript etc. Everything that is required at runtime for your CLI should go into dependencies
.
I think the best approach is to have the CLI in a separate package, similar to express-generator which is a CLI for express.
Even if it's crucial for development, your library users would need to type just one extra command, npm install library-cli
, and if this is properly documented I don't see any problems.
You could also add a postinstall
script or a custom script to your main library that installs the CLI after the package is installed:
"scripts":
"postinstall": "npm install -g library-cli"
However it's also fine if you chose to bundle your CLI with the main library, however in this case you should not put the CLI dependencies into devDependencies
. All the modules that are required to run the cli should go into dependencies
even if 90% of the users would never use them.
devDependencies
should be used for all the tools that are required in the build process, like minification, tests, typescript etc. Everything that is required at runtime for your CLI should go into dependencies
.
answered Nov 12 at 12:45


mihai
23.2k73968
23.2k73968
Sorry to be clear I mean the CLI is crucial for development of the library itself (i.e. for me to use when coding the library). Users of the library (other programmers) wouldn't use the CLI, however end-users (non-coders) should get the CLI installed if they install globally withnpm install -g
so that they have some way of using what they just installed. I agree that putting the CLI into a separate package would be cleaner, but it unfortunately will complicate the dev process for the library so I'm wondering if I can avoid that.
– Malvineous
Nov 13 at 23:46
1
ok, I see. I would create a new package and add the cli as indevDependencies
for the main library, while the dependencies for the cli go in that separate package independencies
. That's how I would put it, but on the other hand there are lots of libraries which download extra stuff that's not used, so putting everything in the same package won't be such a big problem. Ultimately it's up to you.
– mihai
Nov 14 at 9:41
Interesting idea, I think that is probably the cleanest way to do it, thanks!
– Malvineous
Nov 15 at 8:56
add a comment |
Sorry to be clear I mean the CLI is crucial for development of the library itself (i.e. for me to use when coding the library). Users of the library (other programmers) wouldn't use the CLI, however end-users (non-coders) should get the CLI installed if they install globally withnpm install -g
so that they have some way of using what they just installed. I agree that putting the CLI into a separate package would be cleaner, but it unfortunately will complicate the dev process for the library so I'm wondering if I can avoid that.
– Malvineous
Nov 13 at 23:46
1
ok, I see. I would create a new package and add the cli as indevDependencies
for the main library, while the dependencies for the cli go in that separate package independencies
. That's how I would put it, but on the other hand there are lots of libraries which download extra stuff that's not used, so putting everything in the same package won't be such a big problem. Ultimately it's up to you.
– mihai
Nov 14 at 9:41
Interesting idea, I think that is probably the cleanest way to do it, thanks!
– Malvineous
Nov 15 at 8:56
Sorry to be clear I mean the CLI is crucial for development of the library itself (i.e. for me to use when coding the library). Users of the library (other programmers) wouldn't use the CLI, however end-users (non-coders) should get the CLI installed if they install globally with
npm install -g
so that they have some way of using what they just installed. I agree that putting the CLI into a separate package would be cleaner, but it unfortunately will complicate the dev process for the library so I'm wondering if I can avoid that.– Malvineous
Nov 13 at 23:46
Sorry to be clear I mean the CLI is crucial for development of the library itself (i.e. for me to use when coding the library). Users of the library (other programmers) wouldn't use the CLI, however end-users (non-coders) should get the CLI installed if they install globally with
npm install -g
so that they have some way of using what they just installed. I agree that putting the CLI into a separate package would be cleaner, but it unfortunately will complicate the dev process for the library so I'm wondering if I can avoid that.– Malvineous
Nov 13 at 23:46
1
1
ok, I see. I would create a new package and add the cli as in
devDependencies
for the main library, while the dependencies for the cli go in that separate package in dependencies
. That's how I would put it, but on the other hand there are lots of libraries which download extra stuff that's not used, so putting everything in the same package won't be such a big problem. Ultimately it's up to you.– mihai
Nov 14 at 9:41
ok, I see. I would create a new package and add the cli as in
devDependencies
for the main library, while the dependencies for the cli go in that separate package in dependencies
. That's how I would put it, but on the other hand there are lots of libraries which download extra stuff that's not used, so putting everything in the same package won't be such a big problem. Ultimately it's up to you.– mihai
Nov 14 at 9:41
Interesting idea, I think that is probably the cleanest way to do it, thanks!
– Malvineous
Nov 15 at 8:56
Interesting idea, I think that is probably the cleanest way to do it, thanks!
– Malvineous
Nov 15 at 8:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244254%2fdo-a-utility-programs-dependencies-go-into-the-devdependencies%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
IcUPN d,BNzB5zmFI10,8RWpbfKZ puw D IlzvGmd8YJEg9uGRr,biL,rUK83g