npm WARN … requires a peer of … but none is installed. You must install peer dependencies yourself

前端 未结 10 847
不知归路
不知归路 2020-11-29 15:44

I tried to run a project downloaded from github. Unfortunately, during npm install the following warnings were shown. I tried to change the version based on thi

相关标签:
10条回答
  • 2020-11-29 16:08

    For each error of the form:

    npm WARN {something} requires a peer of {other thing} but none is installed. You must install peer dependencies yourself.
    

    You should:

    $ npm install --save-dev "{other thing}"
    

    Note: The quotes are needed if the {other thing} has spaces, like in this example:

    npm WARN rollup-plugin-uglify@6.0.3 requires a peer of rollup@>=0.66.0 <2 but none was installed.
    

    Resolved with:

    $ npm install --save-dev "rollup@>=0.66.0 <2"
    
    0 讨论(0)
  • 2020-11-29 16:12
    npm install -g npm-install-peers
    

    it will add all the missing peers and remove all the error

    0 讨论(0)
  • 2020-11-29 16:15

    In my case following commands worked for me:

    sudo npm cache clean --force
    sudo npm install -g npm
    
    
    sudo apt install libssl1.0-dev
    sudo apt install nodejs-dev
    sudo apt install node-gyp
    sudo apt install npm
    

    After that if you are facing "Cannot find module 'bcrypt' then for that you can resolve this one with below commands:

    npm install node-gyp -g
    npm install bcrypt -g
    npm install bcrypt --save  
    

    Hope it will work for you as well.

    0 讨论(0)
  • 2020-11-29 16:15

    Had the same issue installing angular material CDK:

    npm install --save @angular/material @angular/cdk @angular/animations
    

    Adding -dev like below worked for me:

    npm install --save-dev @angular/material @angular/cdk @angular/animations
    
    0 讨论(0)
  • 2020-11-29 16:19

    "A requires a peer of B but none was installed". Consider it as "A requires one of B's peers but that peer was not installed and we're not telling you which of B's peers you need."

    The automatic installation of peer dependencies was explicitly removed with npm 3.

    NPM Blog

    Release notes of v3

    So you cannot install peer dependencies automatically with npm 3 and upwards.

    Updated Solution:

    Use following for each peer dependency to install that and remove the error

    npm install --save-dev xxxxx
    

    Deprecated Solution:

    1. You can use npm-install-peers to find and install required peer dependencies.

      npm install -g npm-install-peers

      npm-install-peers

    2. If you are getting this error after updating any package's version then remove node_modules directory and reinstall packages by npm install or npm cache clean and npm install.

    0 讨论(0)
  • 2020-11-29 16:28

    total edge case here: I had this issue installing an Arch AUR PKGBUILD file manually. In my case I needed to delete the 'pkg', 'src' and 'node_modules' folders, then it built fine without this npm error.

    0 讨论(0)
提交回复
热议问题