MoniruzzamanBappy / nexcade-ui

0 stars 0 forks source link

nexcade package doesnt run on local for react version problem #1

Closed MoniruzzamanBappy closed 1 day ago

MoniruzzamanBappy commented 1 day ago

The Nexcade UI package may specify a different version of React in its peerDependencies than the version required in your local project. This issue commonly occurs if the package was developed with an older or newer version of React. The error usually looks something like:

npm ERR! Could not resolve dependency: peer react@"^17 || ^18" from nexcade-ui
npm ERR! node_modules/nexcade-ui
MoniruzzamanBappy commented 1 day ago

Solution: Update peerDependencies and Reinstall with Compatibility Adjust peerDependencies in package.json: Ensure that your Nexcade UI library’s package.json file includes a flexible peerDependencies specification that allows multiple versions of React (e.g., both React 17 and 18).

// Nexcade UI package.json
{
  "peerDependencies": {
    "react": "^17 || ^18",
    "react-dom": "^17 || ^18"
  }
}

Reinstall with Compatibility Flags: When installing Nexcade UI or other dependencies, use the --legacy-peer-deps flag to bypass dependency conflicts.

npm install nexcade-ui --legacy-peer-deps

Code Example for Compatibility Check

In your local project, ensure you are importing Nexcade UI components correctly and verify that React is compatible.

import React from "react";
import { Header, Footer, Spinner } from "nexcade-ui";

function App() {
  return (
    <div>
      <Header title="Welcome to Nexcade UI" />
      <Spinner />
      <Footer />
    </div>
  );
}
export default App;