Templarian / MaterialDesign-React

Dist for Material Design Icons React Component for JS/TypeScript
https://materialdesignicons.com
MIT License
139 stars 20 forks source link

Add 'prop-types' as a dependency (or remove it) #60

Closed Ebbe closed 2 years ago

Ebbe commented 3 years ago

This library is dependent of 'prop-types'. Either loose the dependency, or add it as one in package.js instead of a devDependency.

Error after installing @mdi/react and @mdi/js to my app and starting it:

ERROR in ./node_modules/@mdi/react/Icon.js
Module not found: Error: Can't resolve 'prop-types' in '/app/node_modules/@mdi/react'
@ ./node_modules/@mdi/react/Icon.js 1:957-978

Though it is easily fixed on my side by adding 'prop-types' to my own app.

Templarian commented 2 years ago

Interesting, marked this a bug. Found the docs, yeah will need to fix this:

https://github.com/facebook/prop-types#how-to-depend-on-this-package

lafiosca commented 2 years ago

I ran into this problem as well because I'm using Yarn PnP for my project. In that case, adding prop-types to your app's top-level dependencies is not sufficient because Yarn PnP is very strict about packages declaring their dependencies. Additionally, @mdi/react also depends on react without declaring it.

The workaround for me was to add this to the packageExtensions section of my root .yarnrc.yml:

  '@mdi/react@*':
    dependencies:
      prop-types: '^15.5.7'
      react: '*'
willin commented 2 years ago

then how to resolve this?

some-user123 commented 2 years ago

Stumbled across this today as the fix is not published on npm. Any plans to release the fix?