Is a package.json file missing dependencies?

Curious about the meaning of peerDependencies, I examined the contents of this package.json file. It relates to a library project that is distributed elsewhere.

{
    "name": "...",
    "version": "...",
    "description": "...",
    "author": "...",
    "license": "Unlicense",
    "main": "dist/index.js",
    "typings": "dist/index.d.ts",
    "scripts": {
      "build": "typings install && tsc --outDir dist/"
    },
    "peerDependencies": {
        "@angular/core": "^2.0.0",   <<<<<<<<
        "@angular/http": "^2.0.0",   <<<<<<<<
        "@angular/common": "^2.0.0",   <<<<<<<<
        "@angular/compiler": "^2.0.0",   <<<<<<<<
        "core-js": "^2.4.0",   <<<<<<<<
        "reflect-metadata": "^0.1.3",   <<<<<<<<
        "rxjs": "5.0.0-beta.12",   <<<<<<<<
        "zone.js": "^0.6.17"   <<<<<<<<
      },
      "devDependencies": {
        "@angular/core": "^2.0.0",   <<<<<<<<
        "@angular/http": "^2.0.0",   <<<<<<<<
        "@angular/common": "^2.0.0",   <<<<<<<<
        "@angular/compiler": "^2.0.0",
        "@angular/platform-browser": "^2.0.0",   <<<<<<<<
        "core-js": "^2.4.0",   <<<<<<<<
        "reflect-metadata": "^0.1.3",   <<<<<<<<
        "rxjs": "5.0.0-beta.12",   <<<<<<<<
        "zone.js": "^0.6.17",   <<<<<<<<
        "typescript": "^2.0.0",
        "typings": "^1.3.2"
      }
}
  1. Why is the same package listed in both devDependencies and peerDependencies?
  2. Why isn't dependencies used here?

Answer №1

Starting from npm 3, peerDependencies are no longer automatically fetched when installing a package. Instead, npm will now issue a warning if a dependency is missing.

The rationale behind organizing a package.json in this way could be:

  • Developers working on this package are required to install the dependencies listed under devDependencies.

  • Users utilizing this package may not need to download the dependencies if they already exist in their project. However, in case they do not have them installed yet, the inclusion of peerDependencies ensures that they receive a warning during installation (which they would then have to resolve manually).

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

Properties for a standard React component

Currently, I am developing a form component in react with typescript that requires a 'fieldStructures' and an 'onSubmit' prop. type FieldStructure { type: 'text'; name: string; label?: string; helpText?: string ...

Unable to deploy Azure App Service due to difficulties installing node modules

My Azure Node.js App Service was created using a tutorial and further customization. The app is contained within one file: var http = require("http"); //var mongoClient = require("mongodb").MongoClient; // !!!THIS LINE!!! var server = http.createServer(f ...

Is it possible to customize a VSCode extension to function exclusively with certain programming languages?

Lately, I added a new extension to my VSCode setup that has proven to be quite beneficial for my workflow. If you're interested, you can find this helpful extension at This Repository. It allows you to easily highlight the starting and ending syntax ...

What is the best way to utilize project references with multiple tsconfig files?

Let's say I have three separate projects to work on: shared frontend backend In order to use the shared project as a reference in both the frontend and the backend, I need to make a few adjustments. The backend utilizes commonjs modules while the fr ...

What is the best way to eliminate a specific set of characters from a string using TypeScript?

Imagine you have the following lines of code stored in a string variable: let images='<img alt="image1" height="200" src="image1.jpg" width="800"> <img alt="image2" src="image2.jpg" height="501" width="1233"> <img alt="im ...

npm uninstall can sometimes hang or operate very slowly with no visible activity

I've always noticed that when executing npm uninstall, it tends to take longer than expected. Currently, I initiated the uninstall process for four packages approximately 25 minutes ago, yet it seems to have halted with no visible progress, no noticea ...

Utilizing i18next for both a custom Typescript library and a host simultaneously: a step-by-step guide

Currently, I am in the process of developing a typescript library that is designed to take in an object and generate an excel file. This library is intended for use with multiple React applications. Each React application, or host, will provide its own obj ...

Combining default and named exports in Rollup configuration

Currently, I am in the process of developing a Bluetooth library for Node.js which will be utilizing TypeScript and Rollup. My goal is to allow users to import components from my library in various ways. import Sblendid from "@sblendid/sblendid"; import S ...

Upon completing the installation of the @angular/cli@latest node module, the ng file was unexpectedly missing

I'm currently working on Git Bash on my Windows 10 machine. The command I used was: npm install --save @angular/cli@latest Here is the result: + @angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bad9d6d3fa8b899488 ...

Removing empty options from a select dropdown in Angular 9

In the process of working with Angular 9, I am currently in the process of constructing a dropdown menu that contains various options. However, I have encountered an issue where there is a blank option displayed when the page initially loads. How can I eli ...

The reason for the failure of yarn publish is due to the inclusion of the dist folder in the

When it comes to publishing a node module using Yarn, there is an issue with adding a git tag because the dist folder is included in the .gitignore file. yarn publish dist Output: The following paths are ignored by one of your .gitignore files: d ...

Strategies for enhancing performance in an Angular 4 project

Currently, I am engaged in a project that involves utilizing Angular 4 for the front-end and PHP for the back-end with the support of an Apache server on Ubuntu 16.04 LTS. We have incorporated Node JS to facilitate the functionality of Angular. This raises ...

Steps for setting up an Angular project as a dependency in the package.json file of another Angular project

I currently have three separate Angular cli projects labeled as X, Y, and Z. My goal is to designate [X] as the parent project and include Y and Z as npm package dependencies within X. This means that the package.json file for [X] will list the dependencie ...

What is the best way to transfer the userId from the browser to protractor?

Using *ngFor in my angular2 component to render users has been successful. <ul> <li *ng-for="let user of users"> <input [(ng-model)]="user.name"> <button (click)="remove(user._id)">Remove</button> ...

Error Message: The Reference.update operation in Angular Firebase failed due to the presence of undefined value in the 'users.UID.email' property

Having recently started to use the Firebase database, I encountered an issue while trying to update the UID to the Realtime Database during signup. The error message displayed was: Error: Reference.update failed: First argument contains undefined in prop ...

Struggling to use the bind method for the loadScene callback function in cocosCreator or cocos2d-x?

When the loadScene() callback function is bound, the information retrieved from getScene() becomes inaccurate. Upon transitioning from the Entry Scene to the Lobby Scene, I perform post-processing tasks. The implementation was done in TypeScript. Entry. ...

Showing an error message upon submission in Angular 4 according to the server's response

Struggling for hours to display an error message when a form submits and returns an error status code. The solution seems elusive... In the login form component below, I've indicated where I would like to indicate whether the form is valid or invalid ...

Module '. ' or its corresponding type declarations cannot be located

While working on my project with TypeScript and using Cheerio, I encountered an issue when trying to compile it with TSC. The compiler threw the following exception: error TS2307: Cannot find module '.' or its corresponding type declarations. 2 ...

Converting retrieved data into table cells through mapping

I'm facing an issue where I need to display specific addresses for each individual in a table row. For simplicity, let's focus on showing the city specifically as described in this code snippet: https://i.stack.imgur.com/bJmsD.png Currently, whe ...

The type does not contain a property named `sort`

"The error message 'Property sort does not exist on type (and then shoes4men | shoes4women | shoes4kids)' pops up when attempting to use category.sort(). I find it puzzling since I can successfully work with count and add a thousand separato ...