question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dependencies (package.json [dev]Dependencies) cannot be commented (locally in manifest)

See original GitHub issue

Which @angular/* package(s) are relevant/related to the feature request?

common

Description

Dependencies of an Angular application are specified in the dependencies (and devDependencies) key of package.json, as documented in Workspace npm dependencies. This structure is inherited from npm, and with it comes a limitation which has been known for a long time and discussed in more than one place.

While the dependencies can be specified one per line in a readable way, it is (basically - hacks ignored) not possible to add a comment about a given dependency on the same line (or on the line above). This limitation itself comes from the format used by npm, JSON.

There are many reasons to comment dependencies. I work on a single Angular project which is not huge, but we have well over 30 direct dependencies, and I have hit problems which could have been avoided or largely mitigated by simply commenting dependencies, more than once just during this quarter. For example, today I needed to add a version constraint on our dependency on @types/node to workaround DefinitelyTyped #55430, and it already looks like that constraint may become unnecessary in a matter of days thanks to an upstream fix. But since I couldn’t justify it right in the manifest, that constraint could remain unwarranted for a long time because no one wants to take a chance. Other reasons to comment a dependency include indicating that:

  • it should be removed
  • it should be updated (but there have been issues with an earlier attempt)
  • it could be replaced with an alternative rather than updated
  • it is deprecated in favor of another dependency
  • it is low-quality

Proposed solution

The obvious solution would be to support an alternative to npm which supports manifests in a format richer than strict JSON (such formats include JSON5, JSON6, and the better-known XML and YAML). The only alternative which looks serious that I see is pnpm, which supports JSON5 and YAML.

Disclaimer: I have never used pnpm, and while it is obviously better than npm on that front, I cannot even claim that pnpm is generally superior to npm.

Alternatives considered

  • yapm is an npm alternative which supports YAML, but which despite its great name would apparently require lots of effort to bring to maturity.
  • Insisting for npm itself to introduce support. While the original ticket was closed by an npm developer who constructively complained of “bikeshedding”, a newer and more much articulated ticket has replaced it.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JoostKcommented, Dec 11, 2021

The goal of the Angular project is not to provide custom package management features. https://github.com/npm/rfcs/issues/291 seems to be the right place for this request (thank you for providing this context up front).

1reaction
Chealercommented, Sep 1, 2021

Thanks @itea-dev There are obviously a number of workarounds indeed possible, some of which are mentioned in the Techiediaries article linked above and in npm issue #4482.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'npm start' returns error: "There might be a problem with the ...
Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder. Run npm install or yarn, depending on ...
Read more >
Adding dependencies to a package.json file - npm Docs
To add dependencies and devDependencies to a package.json file from the command line, you can install them in the root directory of your...
Read more >
Extension Manifest - Visual Studio Code
Any runtime Node.js dependencies your extensions needs. Exactly the same as npm's dependencies . devDependencies, object, Any development Node.
Read more >
npm packages in the Package Registry - GitLab Docs
In the GitLab project that houses your .npmrc and package.json , edit or create a ... You cannot use your CI_JOB_TOKEN or deploy...
Read more >
SharePoint Framework toolchain | Microsoft Learn
The package.json file in the client-side project specifies the list of dependencies the project depends on. The list defines what dependencies ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found