Reputation: 795
I am working on a react js application where I am using Material-UI v5.0.0 for my UI components. This new version replaces the package names from @material-ui/* prefix with @mui/*:
@material-ui/system -> @mui/system
@material-ui/styles -> @mui/styles
@material-ui/lab -> @mui/lab
In my project I am also using another dependency for displaying a calendar on 1 page which has a peer dependency of Material-UI v4.12.3 which imports material libraries like @material-ui/system
.
How should I manage my dependencies in package.json so that I can use Material-UI v5.0.0 for majority of my UI/UX and still be able to use the dependency just for a specific UI screen.
Should I npm install both material UI v5.0.0 and v4.12.3 or is there a better way of doing this ?
Upvotes: 4
Views: 3172
Reputation: 2286
With npm or yarn you may install specific packages under aliased names enabling you to use the same package under two different versions to do so you may
npm install <alias>@npm:<pkg_name><@version> # for npm
yarn add <alias>@npm:<pkg_name><@version> # for yarn
Example:
Installing Material-UI
npm install v5n@npm:@mui/[email protected]
npm install v4n@npm:@mui/[email protected]
Then you may require them as
import Button from 'v5/Button';
Upvotes: 7