When upgrading to latest version of SPFx which is 1.15 (as of writing this article), I got the following error.

npm ERR ERESOLVE unable to resolve the dependency tree.

As you know to install the SPFx following steps need to be performed in sequence.

  • Installing Node
  • Installing Gulp
  • Installing Yeoman
  • Installing the Yeomen Generator for SharePoint

The official node version for SPFX 1.15 is Node.js v16.

To install the SPFx or to set up SPFx developer environment please go through the below articles which have detailed steps.

Fixing Vulnerabilities

When installing yeomen there are no issues but vulnerabilities. It is advised to fix the vulnerabilities

As mentioned in the screenshot ran the npm audit fix and the vulnerabilities found are 0.

SPFx Install Error

When Installing the SharePoint generator by running the following command

Npm install @microsoft/generator-sharepoint –global

It gave the following error ‘code ERESOLVE’, ‘ERESOLVE unable to resolve the dependency tree’.

To overcome this issue it is required to add the optional parameter –legacy-peer-deps

As you see the installation is now completed. It also warned about vulnerabilities, which are also fixed by running following npm audit fix command.

To finally know the version of the SharePoint framework or the version of the SPFx that is installed please run the following command.

What does “–legacy-peer-deps ” do?

The parameter flag –legacy-peer-deps introduced in node version v7 as a way to bypass peerDependency auto installation. In other words this flag telling node engine to “Not To Install Any Legacy Dependencies”.

Now let’s try understanding Dependencies vs Peer Dependencies:

  • Dependencies can be defined as modules are libraries which are installed in node_modules folder which is needed for NPM (Node Packet Manager) to work properly for designing and deploying the components. For example if you want to install Visual Studio 2022 in your machine, one of the required .net framework is 4.8 which is installed during the installation of the product. For Visual studio to work properly the dependency software we can say it as .Net Framework version 4.8.
  • Peer Dependency (peerDependency) can be defined as set of libraries or modules with specific versions are required to run the project or to work with the component. Let’s assume that you have built a software which is developed using visual studio 2019 targeted to framework version 4.5.2. In order for the software to work properly the client machine should have .Net framework version 4.5.2 where the software is installed. In this case for your specific/custom software .Net framework 4.5.2 is Peer Dependency.

Hope you find this article useful. Please let me know for any questions or concerns in comments section. hostforlifebanner