Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
511 views
in Technique[技术] by (71.8m points)

npm - Possible to use only one package version using pnpm?

I need to use apollo-server and graphql-upload to handle file uploads. This is working as expected with the old graphql-upload v9. Updating to the latest v11 results in failing uploads. To make it short, the problem is, that apollo-server (and @nestjs/graphql) are depending on the old graphql-upload v8. (For those, who are interested in more) To get everything working, there should only be one version (v11) in my project.

I'm using pnpm. Listing which packages are using graphql-upload I get following:

@nestjs/graphql 7.9.1
├─┬ @apollo/gateway 0.17.0
│ └─┬ apollo-server-core 2.19.0
│   └── graphql-upload 8.1.0      // <--
├─┬ apollo-server-core 2.16.1
│ └── graphql-upload 8.1.0        // <--
└─┬ apollo-server-testing 2.19.0
  └─┬ apollo-server-core 2.19.0
    └── graphql-upload 8.1.0      // <--
apollo-server 2.19.0
├─┬ apollo-server-core 2.19.0
│ └── graphql-upload 8.1.0        // <--
└─┬ apollo-server-express 2.19.0
  └─┬ apollo-server-core 2.19.0
    └── graphql-upload 8.1.0      // <--
graphql-upload 9.0.0              // <-- only working if <v10
question from:https://stackoverflow.com/questions/65602563/possible-to-use-only-one-package-version-using-pnpm

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You may use pnpm overrides. In your case, you would add this to your package.json:

{
  "pnpm": {
    "overrides": {
      "graphql-upload": "11"
    }
  }
}

After adding or changing these overrides, just run pnpm install and pnpm will update your node_modules accordingly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...