Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peer dependencies not installed (inconsistent with modern npm) #1031

Closed
1 task done
cefn opened this issue Apr 13, 2023 · 4 comments
Closed
1 task done

Peer dependencies not installed (inconsistent with modern npm) #1031

cefn opened this issue Apr 13, 2023 · 4 comments
Labels

Comments

@cefn
Copy link

cefn commented Apr 13, 2023

Describe the bug

I was experimenting with running an app from github like this...

https://stackblitz.com/github/cefn/watchable/tree/80692ad0ec8a8ae11b90ed8ea5892e3535014f7e/apps/counter-dom-js?file=README.md

Unfortunately, the behaviour of stackblitz with respect to peerDependencies of dependencies seems to be non-standard.

In this commit the referenced version of @lauf/store-follow has a peer dependency of @lauf/queue declared but @lauf/queue was not installed leading to a failure of the app.

By contrast downloading that folder and running npm install && npm run dev DOES install @lauf/queue as expected by npm standards since npm 7.

A workaround for stackblitz is to fork the app and manually add the proper version of @lauf/queue which DOES then work.

Link to the blitz that caused the error

https://stackblitz.com/github/cefn/watchable/tree/alpha-release/apps/counter-dom-js?file=package.json

Steps to reproduce

Visit https://stackblitz.com/github/cefn/watchable/tree/80692ad0ec8a8ae11b90ed8ea5892e3535014f7e/apps/counter-dom-js?file=README.md
and observe failure.

Expected behavior

The peerDependencies of dependencies ARE installed and the app does not fail.

Parity with Local

Screenshots

No response

Platform

Browser name  = Chrome
Full version  = 109.0.0.0
Major version = 109
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (X11; CrOS x86_64 15236.80.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
performance.memory = {
  "totalJSHeapSize": 83182259,
  "usedJSHeapSize": 53512071,
  "jsHeapSizeLimit": 2172649472
}
Hash = 9926f97d

Additional context

No response

@cefn
Copy link
Author

cefn commented Apr 14, 2023

Note the following...

UPDATE: npm versions 1, 2, and 7 will automatically install peerDependencies if they are not explicitly depended upon higher in the dependency tree. For npm versions 3 through 6, you will receive a warning that the peerDependency is not installed instead.

https://nodejs.org/en/blog/npm/peer-dependencies

which suggests that either showing a warning OR providing the dependency is required by every version of NPM, with the modern versions - post 7 doing an actual install of peerDependencies.

@cefn
Copy link
Author

cefn commented Apr 14, 2023

As a workaround I'm going to follow the guidance of npm/rfcs#324 which seems supported since 7.5.5 meaning my package will (in npm) install a hard dependency if its peer dependency is not satisfied.

This will also act as a workaround for non-standard handling of peerDependencies. However it comes at the cost of duplicates, which may lead to real bugs when projects are run in Stackblitz and (duplicate) dependencies are installed when they should be (deduped) peer dependencies. See https://nodejs.org/api/packages.html#dual-package-hazard.

@Nemikolh
Copy link
Member

Hi @cefn ! Thanks for the report.

We are planning to release native npm support which should solve most of your issues. Right now, npm is an alias to turbo our custom package manager and it works a bit differently.

We'll keep you posted.

@jrvidal
Copy link
Contributor

jrvidal commented May 10, 2023

Closing as duplicate of #1070, you can track progress there!

@jrvidal jrvidal closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants