Comparing npm install --save versus npm install --save-dev

Hey everyone, I've been using npm install -g to globally install node modules/packages, but I'm a bit confused about the --save and --save-dev options.

I tried looking it up on Google, but I'm still not entirely sure. Can you guys help clarify this for me?

Answer №1

--save will include a third-party package in the dependencies of your package, ensuring it is installed whenever someone runs npm install yourPackage.

--save-dev adds a third-party package to the development dependencies of your package. This means it won't be automatically installed when someone installs your package but can be added when cloning your source repository and running npm install.

Development dependencies are specifically for tools needed during the development process like test runners, compilers, and packagers.

These dependency types are detailed in the package.json file, with --save adding to dependencies, and --save-dev adding to devDependencies. The official npm documentation explains this furtherhere.

devDependencies

If others plan on using your module in their programs, they may not need to download and build external frameworks like testing or documentation tools that you use.

In such cases, organizing these items in a devDependencies object is recommended.

These items will only be installed when running npm link or npm install from the root directory of the package and can be managed like any other npm configuration parameter. Refer to npm-config(7) for more information.

For non-platform-specific build processes (such as converting CoffeeScript to JavaScript), utilize the prepublish script and designate the required package as a devDependency.

Edit: With the release of npm 5.0.0, installed modules are now automatically considered dependencies, rendering the --save option unnecessary.

Answer №2

  • --save-dev is essential for developers to save packages for tasks such as unit tests and minification.
  • --save ensures that the required packages for running the application are saved correctly.

Answer №3

  1. --save-dev allows npm modules to be saved in the development dependencies section of package.json, specifically within the devDependencies object.
  2. --save enables npm modules to be saved in the dependencies section of package.json, specifically within the dependencies object.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to showcase the output of a Perl script on a webpage

I recently came across a resource discussing the process of executing a perl script from a webpage. What is the best way to run a perl script from a webpage? However, I am facing a situation where the script I have takes more than 30 seconds to run and d ...

How to achieve a reverse slideToggle effect with jQuery when refreshing the page

After creating a custom menu on Wordpress using jQuery slideToggle to toggle dropdown on hover, everything seemed to be working perfectly. However, I noticed that when I refreshed the page while moving my cursor between two menu items with dropdown menus, ...

instructions for executing this javascript within the <p> tag

This is the code I have written : <p onload=javascript:alert('sss')>www</p> Unfortunately, the code does not alert 'sss', Can someone please tell me what's wrong with my code? Thank you ...

Packages installed on a global level continue to be duplicated on a local level

For my development environment, I rely solely on node.js tools like grunt, uglify, sass, and bower (placed in devDependencies, not for production use). Managing multiple projects with the same set of tools can be cumbersome, especially when moving them ar ...

Encountering a problem while installing an Angular 2 npm package from an enterprise registry

We are utilizing an enterprise repository for NPM packages that mirrors the traditional registry "http://registry.npmjs.org/". I am currently attempting to fetch the following packages (listed in package.json) "@angular/common": "2.0.0-rc.4", "@angular/co ...

Exploring nested static properties within TypeScript class structures

Check out this piece of code: class Hey { static a: string static b: string static c: string static setABC(a: string, b: string, c: string) { this.a = a this.b = b this.c = c return this } } class A { static prop1: Hey static ...

Repeated firing of jQuery's Ajaxstop within a click event

When using the quantity plus button on the woocommerce cart page and reaching maximum stock, I want to display a notice. However, due to an auto update on the cart, I have to wait for the ajax load to complete before showing the notice. My script revealed ...

tips for concealing a row in the mui data grid

I am working on a data grid using MUI and I have a specific requirement to hide certain rows based on a condition in one of the columns. The issue is that while there are props available for hiding columns, such as hide there doesn't seem to be an eq ...

An error has occurred: String cannot have property 'innerText' created

I'm encountering an issue while attempting to dynamically add posts to my post div. The problem arises when I try to include image URLs in the process. Switching from innerText to innerHTML did not resolve the issue, and the array I added is also not ...

SyntaxError: Identifier was not expected

I am currently working on a function that involves a table of rows with edit buttons. Whenever the edit button is clicked, the following function is called and I encounter this error: Uncaught SyntaxError: Unexpected identifier The error seems to be poin ...

tips for concealing the shadow of a draggable div during the dragging process

I am facing an issue with a draggable div. When I drag the div, the shadow also moves along with it. I want to find a way to hide this shadow while dragging. <div draggable="true" (dragstart)="mousedown($event)" (drag)="dra ...

JavaScript: A pair of radio button selections

I'm facing an issue with a short form that has two questions and radio buttons for answers. When the first question is answered "No," I used JS code to disable options for the second question, which works fine. However, if the answer is changed back t ...

Unable to compile an Ionic 5 (angular) application with Node.js versions 12.22.12 or 12.22.6

I'm facing a challenge with an old app that requires me to run it using nvm for compatibility with older versions of node.js and ionic. Despite the outdated dependencies, I simply need to get it running in a development environment. Upon attempting t ...

Attempted to utilize zipstatic but received no feedback

I attempted to utilize the Zipstatic API with jQuery in my code, as shown below. However, I am not receiving any response. Could there be something missing? jQuery(function() { jQuery("#form").hide(); jQuery("#postcode").keyup(function() { var c ...

Ways to expand a Bootstrap input field by clicking on it:

I have successfully created a search bar in my navbar, but I am looking to add functionality that allows the input field to expand to its normal size when clicked. I believe this will require some JavaScript implementation, however, I am unsure how to proc ...

JavaScript CheckBox Color Change Not Functioning

Hello, I am currently experimenting with the checkAll function. When I click on the checkAll checkbox, it should select all rows and change their background color accordingly. Below is the JavaScript code I am using: function checkAll(objRef) { v ...

Ways to ensure the text on my website scrolls into view as the user navig

Is there a way to have my text show up as I scroll? I came across this , but I'm interested in how it actually functions. I saw a similar inquiry before, but it doesn't make sense to me. Can someone please explain or provide some examples on how ...

Using AJAX, JQuery, and PHP to convert a given name to match the columns in a query, utilizing the data sent

One thing that I'm wondering about is how PHP handles my ajax requests. For example, consider the following code snippet: $("#addUser").on('click', '.btnAddSubmitFormModal', function() { $.post("add.php", { ...

Guide on using Twitter Typeahead.js to capture all matching elements in a specific string

When using twitter typeahead.js, it typically returns elements that match only at the beginning of a string. For example: source: ['type','typeahead','ahead'] query: 'type' Returns: 'type' and 'type ...

How can I display a Skeleton when pressing pagination buttons and then turn it off after 3 seconds?

Here is a snippet of my code featuring the use of a Skeleton as a placeholder for CardMedia: {loading ? ( <Skeleton variant="rectangular" width={308} height={420} animation="wave" /> ) : ( <CardMedia s ...