-
Notifications
You must be signed in to change notification settings - Fork 23
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
[yarn 2] Cannot find module '@octokit/core' or its corresponding type declarations #124
Comments
It's only importing types, not code, so it's not a runtime dependency, only a build-time dependency |
And you cannot use the plugin without also having |
It is a problem because the typescript compiler looks at your code when my code depends on it, and the typescript compiler can't find |
You can read up on this yarn v2 distinct behavior in the link I put in the issue description. |
sounds like a problem with yarn 2 to me, maybe report the problem with them? I cannot fix one problem and introduce another. There might be a more elegant solution, but I don't know what it would look like. I just use the types for convenience when working on this plugin, it has no impact whatsover to users of the plugin. |
What problem would you introduce?
They know about it. Did you read the link I shared? They allow for it by offering a "looseMode" which I've activated. But I agree with their take that this is a bug in your code. Just imagine in abstract: I ship an NPM package with typings included that rely on types defined in another package. If I don't have a dependency expressed on that other package, anyone consuming my package would be unable to be consumed by a typescript user because typescript wouldn't be able to find the typings from the transitive package that wasn't added as a dependency. So this repros without yarn 2 and therefore isn't yarn 2's fault. |
I just found the problem you say would be introduced on the PR:
I am not an expert in npm version handling, but I thought that if you express your minimum version (e.g. And anyway FWIW, I do see many npm packages that do get brought in with multiple versions in an app and I've never seen it cause a problem. |
I'm glad the problem is not blocking for you. I do plan to eventually set If we added "peerDependencies": {
"@octokit/core": ">=3"
} would that resolve the complaining from Yarn 2? |
I'm not sure. I suspect it would. I'm not sure how to test it in advance, but maybe I can find a forum to ask the yarn v2 folks. |
Usually every pull request has their own npm build, so you can install directly from every pull request, but there are some errors right now: https://github.com/octokit/plugin-paginate-rest.js/pull/128/checks?check_run_id=949586838, I'll look into that. Once that resolved you can send a PR to add the |
using
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html |
Can you please share the exact steps on how you run into this problem? I tried to reproduce it with Yarn 2, and had no problems |
Here is the minimal repo that repros the problem with the shipping npm package: https://github.com/AArnott/OctokitPaginateRest.Repro124 It has just a few commits: one for each step. I'll now proceed to try testing your peerDependencies fix. |
@gr2m I tried to install your package from the PR as the instructions in the PR check prescribed, but it failed:
Any suggestions? |
Can you try again? I think there was an npm registry outage. It worked for me with the latest yarn
|
Oops. Yes it was private. I've fixed that. It's public now. |
I still get the "Invalid descriptor" error. Now that my repo is public, can you try, @gr2m ? |
devDependencies
in project.json
Thanks Andrew, I was able to reproduce the problem. So I'm still not sure what to do about this 🤔 I do not appreciate yarn breaking with the way npm works. For now, please use the "loose" mode. I'm not sure yet how I will address it, and I have other priorities I'm afraid |
Understandable. Thanks for looking into it. |
You can add this to packageExtensions:
"@octokit/plugin-paginate-rest@*":
peerDependencies:
"@octokit/core": "*"
The fix is to declare it as a peerDependency, not just for PnP to work but for node_modules as well
Breaking is the wrong term here, it's more like: yarn now lets you know when you're relying on undefined behaviour. For the current types to work you need the package manager to hoist |
Also apply a workaround for octokit/plugin-paginate-rest.js#124
🎉 This issue has been resolved in version 2.3.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@gr2m I just tested, but it still repros. But it's reproing on v2.3.0 despite my adding 2.3.1 to my package.json file. "@actions/github@npm:^4.0.0":
version: 4.0.0
resolution: "@actions/github@npm:4.0.0"
dependencies:
"@actions/http-client": ^1.0.8
"@octokit/core": ^3.0.0
"@octokit/plugin-paginate-rest": ^2.2.3
"@octokit/plugin-rest-endpoint-methods": ^4.0.0
checksum: 49d606acd5b74a2f3e41c76d5a5d54341943e43b79cb94639c6c01d228263a4a287ac43d02d6c872336ab02962d0a7904b1a821bb5d5966498a78c954e34c3f2
languageName: node
linkType: hard
"@octokit/plugin-paginate-rest@npm:^2.2.3":
version: 2.3.0
resolution: "@octokit/plugin-paginate-rest@npm:2.3.0"
dependencies:
"@octokit/types": ^5.2.0
checksum: 3df28decd7af1c23fb1876ddc988f4c1a386febe1586a7b64d8c8334b3240de4ca4152074bfe83e8517c59d57a574fa3f39326c3ecf029a3f3411f08d576186a
languageName: node
linkType: hard I guess |
Yarn wont update that version since you didn't ask it to (and there is no way to ask it to either atm), so you'll have to remove the |
Very interesting, @merceyz. Thanks for all the tips. I was able to confirm the issue is fixed with |
While consuming this package in yarn v2, I got a compile break because this package consumes
@octokit/core
at runtime:plugin-paginate-rest.js/src/index.ts
Line 8 in fb3e08d
Yet is package.json file claims that this dependency is not needed in production:
plugin-paginate-rest.js/package.json
Lines 27 to 31 in fb3e08d
Yarn's PnP mode catches this error, and I have to workaround it by putting it into loose mode.
The text was updated successfully, but these errors were encountered: