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

[rush] Dependency of dependency not installed #1529

Closed
1 of 2 tasks
RDeluxe opened this issue Sep 15, 2019 · 9 comments
Closed
1 of 2 tasks

[rush] Dependency of dependency not installed #1529

RDeluxe opened this issue Sep 15, 2019 · 9 comments
Labels
repro confirmed The issue comments included repro instructions, and the maintainers reproduced the problem
Projects

Comments

@RDeluxe
Copy link

RDeluxe commented Sep 15, 2019

Please prefix the issue title with the project name i.e. [rush], [api-extractor] etc.

Is this a feature or a bug?

  • Feature
  • Bug

Please describe the actual behavior.

I'm working on a project using NextJs.
I'm using a plugin, @zeit/next-css which has several dependencies in its package.json.

However, none of those are listed in the project node_modules after install (they are indeed present in "common") and thus the project won't compile.

This seems to be the case for a lot of dependencies actually, even though it seems they are correctly setup in package.jon files.

If the issue is a bug, how can we reproduce it? Please provide detailed steps and include a GitHub branch if applicable. Your issue will get resolved faster if you can make it easy to investigate.

Here is a simple repro (based on next-css example)

  • clone the repo

  • rush update

  • npm run build

What is the expected behavior?

The project should compile correctly

If this is a bug, please provide the tool version, Node.js version, and OS.

  • Tool: pnpm
  • Tool Version: 2.15.1 (listed in rush.json)
  • Node Version: v12.1.0
    • Is this a LTS version? No
    • Have you tested on a LTS version? No
  • OS: Windows 10
@sachinjoseph
Copy link
Member

Can you also include the steps to repro the issue?

@RDeluxe
Copy link
Author

RDeluxe commented Sep 16, 2019

Sorry, true I forgot. It's a 2 step process, I added the command to my post. (also fixed a typo, I'm using pnpm and not npm)

@RDeluxe
Copy link
Author

RDeluxe commented Sep 16, 2019

After digging more, it seems next as whole is really not pnpm friendly.

The SSR part expects a flatten node_module folder apparently, I have no idea how to mitigate this.

@octogonz
Copy link
Collaborator

Typically these incompatibilities center around two problems:

  1. A package imports a dependency without declaring it in package.json. We call this a phantom dependency. This is usually easy for the package maintainers to fix. It's often as simple as adding a line to their package.json. To test a proposed fix, with PNPM you can use the common/config/rush/pnpmfile.js hook to patch the incorrect package.json during installation. This is a pretty decent workaround.

  2. A package implements homebrew module resolution that does not conform to the standard. In simple cases, maybe the offending package tries to read ../some-dep/package.json or ../../package.json naively assumping that it got installed in a very specific place in the node_modules tree. In more complex cases (e.g. plugin loaders), they may implement a full node_modules probing algorithm, but without following symlinks correctly. This is a bit harder to fix. They may need to add calls to fs.realpathSync() in the right places, or just replace their custom algorithm with the resolve library.

The first step is getting the maintainer to recognize that their package is doing something incorrect. Even though PNPM and Yarn Plug'n'Play have been around for a long time now, there's unfortunately still a substantial monoculture who are unfamiliar with other installation strategies besides classic NPM.

@RDeluxe
Copy link
Author

RDeluxe commented Sep 16, 2019

Thank you for your answer.

I'm aware that this may be caused by the way Next handle their dependency, even if in this case this is probably more problem number 2. I have no idea how to debug something like this however.

Actually with Next you can have problem at build time (ie: the example provided here) and then at runtime.

I'm not quite sure I can make them do anything about it to be honest, and PNPM's move toward "hoisting" is a sign that the battle is probably lost, sadly.

It would be great to see Rush supporting the new pnpm version v4.0.0-1, I've tried to use both together but it does not work for now (I'm digging in Rush code to see if I can find a fix)

@octogonz octogonz added the repro confirmed The issue comments included repro instructions, and the maintainers reproduced the problem label Sep 16, 2019
@rakeshpatnaik rakeshpatnaik added this to High priority in Bug Triage Sep 16, 2019
@RDeluxe
Copy link
Author

RDeluxe commented Sep 16, 2019

Thanks for your attention, to be honest this should probably be closed for now as it's more a PNPM "issue".

A PR was opened for this : vercel/next-plugins#415

But they closed it for now because they are thinking about a future architecture for CSS handling in Next.js.

However PNPM 4 support would be great.

@sadsa
Copy link

sadsa commented Sep 17, 2019

@RDeluxe - I've been chasing the same issue for days now. In my case, I'm using Parcel as a bundling tool and it seems to be the way modules are being resolved within the parcel-bundler itself. This could potentially be the same issue with NextJS.

See:

@RDeluxe
Copy link
Author

RDeluxe commented Oct 9, 2019

Hey!

I solved my problem by cloning and using my own versions of Next-plugins (applying the aforementionned fixes).

Took me some time though. Good to know that Parcel if unusable with PNPM for now

@apostolisms
Copy link
Contributor

Closing since this seems to be resolved now. thanks

Bug Triage automation moved this from High priority to Closed Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repro confirmed The issue comments included repro instructions, and the maintainers reproduced the problem
Projects
Archived in project
Bug Triage
  
Closed
Development

No branches or pull requests

5 participants