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

ERR_PNPM_PEER_DEP_ISSUES  Unmet peer dependencies and The command '/bin/sh -c pnpm install' returned a non-zero code: 1 #4684

Closed
touchwindfollow opened this issue May 6, 2022 · 35 comments · Fixed by solidjs/solid-meta#10 or #4776

Comments

@touchwindfollow
Copy link

pnpm version: unkown or the latest

Code to reproduce the issue:

we installed the pnpm with dockerfile

dependencies:

  • @element-plus/icons-vue 0.2.7 (1.1.4 is available)
  • axios 0.24.0 (0.27.2 is available)
  • echarts 5.3.2
  • element-plus 2.1.11
  • js-web-screen-shot 1.6.2
  • mitt 3.0.0
  • ol 6.14.1
  • spark-md5 3.0.2
  • vue 3.2.33
  • vue-cache-data 1.5.1
  • vue-router 4.0.15
  • vuex 4.0.2

devDependencies:

  • @babel/core 7.17.10
  • @babel/preset-env 7.17.10
  • @vitejs/plugin-legacy 1.8.2
  • @vitejs/plugin-vue 2.3.2
  • @vue/compiler-sfc 3.2.33
  • @vue/eslint-config-standard 5.1.2 (6.1.0 is available)
  • @vue/test-utils 2.0.0-rc.21
  • @vue/vue3-jest 27.0.0
  • babel-eslint 10.1.0 deprecated
  • babel-jest 27.5.1 (28.0.3 is available)
  • babel-plugin-import 1.13.5
  • eslint 6.8.0 (8.14.0 is available)
  • eslint-plugin-import 2.26.0
  • eslint-plugin-node 11.1.0
  • eslint-plugin-promise 4.3.1 (6.0.0 is available)
  • eslint-plugin-standard 4.1.0 (5.0.0 is available)
  • eslint-plugin-vue 7.20.0 (8.7.1 is available)
  • jest 27.5.1 (28.0.3 is available)
  • jest-transform-stub 2.0.0
  • mockjs 1.1.0
  • regenerator-runtime 0.13.9
  • resize-observer-polyfill 1.5.1
  • sass 1.51.0
  • sass-loader 8.0.2 (12.6.0 is available)
  • unplugin-auto-import 0.6.9 (0.7.1 is available)
  • unplugin-vue-components 0.17.21 (0.19.3 is available)
  • vite 2.9.8
  • vite-plugin-compression 0.5.1
  • vite-plugin-mock 2.9.6
  • vite-plugin-optimize-persist 0.1.2
  • vite-plugin-package-config 0.1.1

 ERR_PNPM_PEER_DEP_ISSUES  Unmet peer dependencies

.
├─┬ @vue/eslint-config-standard
│ └─┬ eslint-import-resolver-webpack
│ └── ✕ missing peer webpack@>=1.11.0
├─┬ sass-loader
│ └── ✕ missing peer webpack@"^4.36.0 || ^5.0.0"
├─┬ unplugin-auto-import
│ └─┬ unplugin
│ ├── ✕ missing peer webpack@"4 || 5"
│ └── ✕ missing peer rollup@^2.50.0
├─┬ unplugin-vue-components
│ └─┬ unplugin
│ ├── ✕ missing peer webpack@"4 || 5"
│ └── ✕ missing peer rollup@^2.50.0
└─┬ vite-plugin-mock
└─┬ @rollup/plugin-node-resolve
├── ✕ missing peer rollup@^2.42.0
└─┬ @rollup/pluginutils
└── ✕ missing peer rollup@^1.20.0||^2.0.0
Peer dependencies that should be installed:
rollup@">=2.50.0 <3.0.0"
webpack@">=4.36.0 <5.0.0 || >=5.0.0 <6.0.0"

The command '/bin/sh -c pnpm install' returned a non-zero code: 1

Expected behavior:

Actual behavior:

Additional information:

dockerfile as follows

FROM node:16-buster-slim

COPY sources.list /etc/apt/

RUN apt-get update

WORKDIR /app
COPY package.json /app/package.json
RUN npm config set legacy-peer-deps true
RUN npm config set registry http://registry.npm.taobao.org
RUN npm install -g pnpm
RUN pnpm install

package.json as follows

{
"name": "frontweb",
"version": "0.1.0",
"private": true,
"scripts": {
"local": "vite --mode mock",
"serve": "vite --mode development",
"serve:patheval": "vite --mode local.patheval",
"serve:pathmedics": "vite --mode local.pathmedics",
"serve:pathanno": "vite --mode local.pathanno",
"pathmedics": "vite --mode pathmedics",
"patheval": "vite --mode patheval",
"build": "vite build --mode production",
"build:pathmedics": "vite build --mode pathmedics",
"build:patheval": "vite build --mode patheval",
"build:nginx:patheval": "vite build --mode nginx.patheval",
"jest": "jest",
"lint": "vite lint"
},
"dependencies": {
"@element-plus/icons-vue": "^0.2.7",
"axios": "^0.24.0",
"echarts": "^5.3.0",
"element-plus": "^2.0.0",
"js-web-screen-shot": "^1.6.2",
"mitt": "^3.0.0",
"ol": "^6.11.0",
"spark-md5": "^3.0.2",
"vue": "^3.2.27",
"vue-cache-data": "^1.5.1",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.2"
},
"devDependencies": {
"@babel/core": "^7.17.7",
"@babel/preset-env": "^7.16.11",
"@vitejs/plugin-legacy": "^1.6.4",
"@vitejs/plugin-vue": "^2.0.1",
"@vue/compiler-sfc": "^3.0.0",
"@vue/eslint-config-standard": "^5.1.2",
"@vue/test-utils": "^2.0.0-rc.18",
"@vue/vue3-jest": "^27.0.0-alpha.3",
"babel-eslint": "^10.1.0",
"babel-jest": "^27.5.1",
"babel-plugin-import": "^1.13.3",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^7.0.0",
"jest": "^27.5.1",
"jest-transform-stub": "^2.0.0",
"mockjs": "^1.1.0",
"regenerator-runtime": "^0.13.9",
"resize-observer-polyfill": "1.5.1",
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
"unplugin-auto-import": "^0.6.6",
"unplugin-vue-components": "^0.17.14",
"vite": "^2.7.2",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-mock": "^2.9.6",
"vite-plugin-optimize-persist": "^0.1.2",
"vite-plugin-package-config": "^0.1.1"
},
"vite": {
"optimizeDeps": {
"include": [
"@element-plus/icons-vue",
"axios",
"echarts/lib/chart/scatter",
"echarts/lib/component/grid",
"echarts/lib/component/markArea",
"echarts/lib/echarts",
"element-plus",
"element-plus/es",
"element-plus/es/components/breadcrumb-item/style/css",
"element-plus/es/components/breadcrumb/style/css",
"element-plus/es/components/button-group/style/css",
"element-plus/es/components/button/style/css",
"element-plus/es/components/checkbox-group/style/css",
"element-plus/es/components/checkbox/style/css",
"element-plus/es/components/col/style/css",
"element-plus/es/components/date-picker/style/css",
"element-plus/es/components/dialog/style/css",
"element-plus/es/components/dropdown-item/style/css",
"element-plus/es/components/dropdown-menu/style/css",
"element-plus/es/components/dropdown/style/css",
"element-plus/es/components/form-item/style/css",
"element-plus/es/components/form/style/css",
"element-plus/es/components/icon/style/css",
"element-plus/es/components/image/style/css",
"element-plus/es/components/input/style/css",
"element-plus/es/components/loading/style/css",
"element-plus/es/components/message/style/css",
"element-plus/es/components/option/style/css",
"element-plus/es/components/pagination/style/css",
"element-plus/es/components/popover/style/css",
"element-plus/es/components/progress/style/css",
"element-plus/es/components/radio-group/style/css",
"element-plus/es/components/radio/style/css",
"element-plus/es/components/row/style/css",
"element-plus/es/components/scrollbar/style/css",
"element-plus/es/components/select/style/css",
"element-plus/es/components/table-column/style/css",
"element-plus/es/components/table/style/css",
"element-plus/es/components/tooltip/style/css",
"element-plus/es/components/upload/style/css",
"element-plus/lib/locale/lang/zh-cn",
"js-web-screen-shot",
"mitt",
"mockjs",
"ol",
"ol/Feature",
"ol/Map",
"ol/ObjectEventType",
"ol/Observable.js",
"ol/Overlay",
"ol/Overlay.js",
"ol/View",
"ol/control",
"ol/events/condition",
"ol/events/condition.js",
"ol/extent",
"ol/geom",
"ol/geom.js",
"ol/interaction",
"ol/interaction.js",
"ol/interaction/Draw",
"ol/layer",
"ol/layer/Vector",
"ol/source",
"ol/source/Cluster",
"ol/source/Vector",
"ol/source/VectorEventType",
"ol/source/Zoomify",
"ol/sphere.js",
"ol/style.js",
"ol/style/Circle",
"spark-md5",
"vue",
"vue-cache-data",
"vue-router",
"vuex"
]
}
}
}

  • node -v prints: from doker_images node:16-buster-slim
  • Windows, macOS, or Linux?: Linux
@M0hammedImran
Copy link

This is happened after the latest release.

@summy00
Copy link

summy00 commented May 6, 2022

This is happened after the latest release.

which release can fix this? thanks!

@M0hammedImran
Copy link

M0hammedImran commented May 6, 2022

This is happened after the latest release.

which release can fix this? thanks!

Try pnpm@^6. This solved the issue for me.

@zkochan
Copy link
Member

zkochan commented May 6, 2022

You don't need to downgrade pnpm. You need to install the missing peer dependencies.

@htmnk
Copy link

htmnk commented May 8, 2022

A .npmrc file with strict-peer-dependencies=false is also an option.

@zkochan I wonder though why was this change added to v7.0.0?

strict-peer-dependencies is true by default #4427

From what I understand it is highly recommended to resolve them but a project can work just fine with the warnings, are there any potential issues when setting strict-peer-dependencies to false? And in that case why are the auto-install-peers=false by default?

@hi-reeve
Copy link

hi-reeve commented May 9, 2022

i got the same error with the newest error

in my case it just doesn't make sense to install all the missing peer dependencies

├─┬ @testing-library/vue
│ └── ✕ missing peer @vue/compiler-sfc@">= 3"
├─┬ unplugin-icons
│ └── ✕ missing peer @vue/compiler-sfc@^3.0.2
├─┬ vite-plugin-pages
│ └── ✕ missing peer @vue/compiler-sfc@>=3
├─┬ vite-plugin-vue-type-imports
│ └── ✕ missing peer @vue/compiler-sfc@^3.2.24
├─┬ motion
│ └─┬ @motionone/react
│   └── ✕ missing peer react@^17.0.2
└─┬ vue-query
  └─┬ react-query
    └── ✕ missing peer react@"^16.8.0 || ^17.0.0 || ^18.0.0"
Peer dependencies that should be installed:
  @vue/compiler-sfc@">=3.2.24 <4.0.0"
  react@">=17.0.2 <18.0.0"

i work using vue 3, but the missing peer dependencies need react.

@all2pie
Copy link

all2pie commented May 9, 2022

Getting same issue, it's working fine with npm

 ERR_PNPM_PEER_DEP_ISSUES  Unmet peer dependencies

.
├─┬ ts-loader
│ └── ✕ missing peer webpack@^5.0.0
├─┬ @nestjs/mercurius
│ └── ✕ missing peer fastify@^3.25.0
├─┬ firebase-admin
│ └─┬ @firebase/database-compat
│   ├── ✕ missing peer @firebase/app-compat@0.x
│   └─┬ @firebase/database
│     └─┬ @firebase/auth-interop-types
│       └── ✕ missing peer @firebase/app-types@0.x
└─┬ @golevelup/nestjs-rabbitmq
  └─┬ @golevelup/nestjs-modules
    ├── ✕ unmet peer @nestjs/common@^7.x: found 8.4.4
    └── ✕ unmet peer rxjs@^6.x: found 7.5.5
Peer dependencies that should be installed:
  @firebase/app-compat@0.x  @firebase/app-types@0.x   fastify@^3.25.0           webpack@^5.0.0

@zkochan
Copy link
Member

zkochan commented May 10, 2022

From what I understand it is highly recommended to resolve them but a project can work just fine with the warnings

Not really. There are two types of peer deps: optional peer dependencies and non-optional ones. The warnings are only printed for non-optional peer dependencies. If a package works without the peer dependencies, then it should be declared as optional peer dependency. Optional peer dependencies are supported by npm/yarn/pnpm for a long time.

Do not ignore these errors. When such issues happen, you should look into it.

i work using vue 3, but the missing peer dependencies need react.

In this case, if you are sure that react is not needed, you can add this to your package.json:

{
  "pnpm": {
    "peerDependencyRules": {
      "ignoreMissing": ["react"]
    }
  }
}

@summy00
Copy link

summy00 commented May 10, 2022

A .npmrc file with strict-peer-dependencies=false is also an option.

@zkochan I wonder though why was this change added to v7.0.0?

strict-peer-dependencies is true by default #4427

From what I understand it is highly recommended to resolve them but a project can work just fine with the warnings, are there any potential issues when setting strict-peer-dependencies to false? And in that case why are the auto-install-peers=false by default?

this works for me, and add this to package.json:

"pnpm": {
    "peerDependencyRules": {
      "ignoreMissing": ["rollup","webpack","types/lodash-es"]
    }
  },

also works for me, thank you @zkochan htmnk

FuckDoctors added a commit to FuckDoctors/notes2 that referenced this issue May 13, 2022
@givebk-bot
Copy link

Hey! Looks like someone invited me to this issue.

@antl3x
Copy link

antl3x commented May 13, 2022

@givebk-bot !donate @zkochan $5

thanks for your solution and your amazing work!

@givebk-bot
Copy link

givebk-bot commented May 13, 2022 via email

@vinkla
Copy link

vinkla commented May 17, 2022

Is there anywhere where one can read the reasoning behind #4427? I'm curious how it works and why it was implemented.

@zkochan
Copy link
Member

zkochan commented May 17, 2022

npm decided to automatically install peer dependencies. We don't automatically install peer dependencies. So projects that work with npm might break for new users of pnpm. We throw these errors because peer dependencies should be added as dependencies to the project.

@vinkla
Copy link

vinkla commented May 17, 2022

Thanks for taking the time to clarify! Is there a flag to automagically install all peer dependencies and add them as dependencies on in a project?

@zkochan
Copy link
Member

zkochan commented May 17, 2022

There is the auto-install-peers=true config but it works only when adding new dependencies with peer dependencies.

@quinnjr
Copy link

quinnjr commented May 19, 2022

Not really. There are two types of peer deps: optional peer dependencies and non-optional ones. The warnings are only printed for non-optional peer dependencies. If a package works without the peer dependencies, then it should be declared as optional peer dependency. Optional peer dependencies are supported by npm/yarn/pnpm for a long time.

I'm having the same issue and it seems to be more of an issue with v7.x.x not respecting

"peerDependenciesMeta": {
    "react": {
      "optional": true
    }
}

v6.x.x did not have the same issue.

@iamsoltan
Copy link

Just downgraded pnpm version to :
npm i -g pnpm@6.32.14
passed the pipeline fine for me

@narwold
Copy link

narwold commented May 20, 2022

I'm experiencing this as well. v7 doesn't seem to respect optional peerDependencies.

@zkochan
Copy link
Member

zkochan commented May 20, 2022

I'm having the same issue and it seems to be more of an issue with v7.x.x not respecting

I am not sure this is true.

I just tested on an empty project. I ran:

pnpm add @jest/reporters@28.1.0

No error happened although @jest/reporters has an option peer dep.

@SaiRS
Copy link

SaiRS commented May 21, 2022

I found the answer which works for me.

function readPackage(pkg) {
  pkg.dependencies = {
    ...pkg.peerDependencies,
    ...pkg.dependencies,
  }
  pkg.peerDependencies = {};

  return pkg;
}

module.exports = {
  hooks: {
    readPackage,
  },
};

The origin answer came from #827 (comment)

@quinnjr
Copy link

quinnjr commented May 21, 2022

I'm having the same issue and it seems to be more of an issue with v7.x.x not respecting

I am not sure this is true.

I just tested on an empty project. I ran:

pnpm add @jest/reporters@28.1.0

No error happened although @jest/reporters has an option peer dep.

I have three repositories that depend on @apollo/client where we have an issue of pnpm throwing errors when react isn't a dependency. @apollo/client only has an optional dependency on react and we don't use it at all since we're using apollo-angular for our Angular-based projects. We are instead getting ERR_PNPM_PEER_DEP_ISSUES being thrown on installation/updates using v7 of pnpm

@zkochan
Copy link
Member

zkochan commented May 21, 2022

When I install @apollo/client, I get this error:

.
└─┬ @apollo/client
  ├── ✕ missing peer graphql@"^14.0.0 || ^15.0.0 || ^16.0.0"
  ├─┬ @graphql-typed-document-node/core
  │ └── ✕ missing peer graphql@"^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
  └─┬ graphql-tag
    └── ✕ missing peer graphql@"^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"

I don't see react there.

@quinnjr
Copy link

quinnjr commented May 21, 2022

When I install @apollo/client, I get this error:

.
└─┬ @apollo/client
  ├── ✕ missing peer graphql@"^14.0.0 || ^15.0.0 || ^16.0.0"
  ├─┬ @graphql-typed-document-node/core
  │ └── ✕ missing peer graphql@"^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
  └─┬ graphql-tag
    └── ✕ missing peer graphql@"^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"

I don't see react there.

issue image

@zkochan
Copy link
Member

zkochan commented May 21, 2022

Which version of apollo client do you have?

@quinnjr
Copy link

quinnjr commented May 21, 2022

Which version of apollo client do you have?

We're depending on @apollo/client as ^3.6.1, so we're currently using 3.6.4

@zkochan
Copy link
Member

zkochan commented May 21, 2022

I was installing 3.6.4 and did not see a warning about React. If you can create a repo that shows the error, open a new issue and link the repo.

@millette
Copy link

millette commented May 21, 2022

In my case:

 WARN  Issues with peer dependencies found
.
└─┬ solid-meta
  └── ✕ unmet peer solid-js@>=^1.4.0: found 1.4.2
millette@pop-os:~/chacre/digigolf-raster (main *%>)$ pnpm -v
7.1.2

As you can see, solid-js is found and the version match, but there's still a warning.

@zkochan
Copy link
Member

zkochan commented May 21, 2022

This seems like an invalid range: >=^1.4.0
It should be either >=1.4.0 or ^1.4.0

@zkochan
Copy link
Member

zkochan commented May 21, 2022

Anyway, the initial issue was about missing peer dependencies and non-zero exit code.

To fix the exit code, set strict-peer-dependencies to false.

To autoinstall peer dependencies, you will soon be able to set the auto-install-peers setting to true. I am working on the feature in this PR: #4776

@millette
Copy link

Thanks @zkochan nice catch.

millette added a commit to millette/solid-meta that referenced this issue May 21, 2022
zkochan added a commit that referenced this issue May 22, 2022
zkochan added a commit that referenced this issue May 22, 2022
@zkochan
Copy link
Member

zkochan commented May 22, 2022

🚢 7.1.3

@visamz
Copy link

visamz commented May 22, 2022

packages/webpack
├─┬ less-loader
│ └── ✕ missing peer less@"^3.5.0 || ^4.0.0"
├─┬ postcss-loader
│ └── ✕ missing peer postcss@"^7.0.0 || ^8.0.1"
└─┬ ts-loader
└── ✕ missing peer typescript@""
Peer dependencies that should be installed:
less@"^3.5.0 || ^4.0.0" postcss@"^7.0.0 || ^8.0.1" typescript@"
"

but in pnpm workspace root already be installed:

    "less": "^4.1.2",
    "node-sass": "^7.0.1",
    "postcss": "^8.4.14", 

pnpm version: 7.1.3

@zkochan
Copy link
Member

zkochan commented May 22, 2022

Peer dependencies are not resolved from the workspace root. It was a breaking change in pnpm v7.

@zkochan
Copy link
Member

zkochan commented May 22, 2022

Just to summarize. Use auto-install-peers=true if you want peer dependencies to be installed automatically.

@pnpm pnpm locked as resolved and limited conversation to collaborators May 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.