fix: add .npmrc with legacy-peer-deps for ERESOLVE errors#675
fix: add .npmrc with legacy-peer-deps for ERESOLVE errors#675imran-siddique merged 1 commit intomicrosoft:mainfrom
Conversation
npm fails to resolve typescript version (shows as 'undefined') during peer dependency checking for ts-jest. Adding legacy-peer-deps=true bypasses strict peer resolution across all packages. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🤖 AI Agent: security-scanner — Security Analysis of the ChangeSecurity Analysis of the ChangeThe addition of the Findings🔴 Supply Chain Risk: Dependency Downgrade and Typosquatting
🟠 Policy Engine Circumvention
🟡 Credential Exposure
Overall Risk Rating: 🔴 CRITICALThe use of Recommendations
By addressing these issues, the project can maintain its integrity as a security-focused library and protect its downstream users from potential vulnerabilities. |
There was a problem hiding this comment.
🤖 AI Agent: code-reviewer
Review Feedback
🔴 CRITICAL
-
Security Implications of
legacy-peer-deps:
Addinglegacy-peer-deps=trueto.npmrcbypasses strict peer dependency checks, which can lead to the installation of potentially incompatible or insecure versions of dependencies. This introduces a risk of pulling in packages with known vulnerabilities or breaking changes that are not properly resolved. While this may resolve immediate ERESOLVE errors, it is not a long-term solution for dependency management in a security-focused library likemicrosoft/agent-governance-toolkit.Actionable Recommendation:
- Investigate and resolve the root cause of the peer dependency conflicts instead of bypassing them.
- Use tools like
npm auditornpm lsto identify problematic dependencies and update them to compatible versions. - Consider pinning dependency versions explicitly in
package.jsonto ensure compatibility.
💡 SUGGESTION
-
Documentation Update:
Iflegacy-peer-deps=trueis temporarily necessary, document the rationale clearly in the repository (e.g., in aREADME.mdorCONTRIBUTING.mdfile). This will help contributors understand why this configuration is being used and encourage them to address the underlying dependency issues. -
Automated Dependency Management:
Consider integrating tools likeDependabotorRenovateto automate dependency updates and ensure compatibility across packages. This can help prevent similar issues in the future.
🟡 WARNING
-
Potential Breaking Changes:
While this change itself does not directly modify the library's public API, the use oflegacy-peer-depsmay lead to unexpected behavior in downstream projects if incompatible dependencies are installed. This could indirectly result in breaking changes for users of the library.Actionable Recommendation:
- Test the library thoroughly after applying this change to ensure that all packages function correctly with the resolved dependencies.
- Communicate any potential risks to users in the release notes or changelog.
Summary
While this change resolves immediate ERESOLVE errors, it introduces security risks and potential compatibility issues. Addressing the root cause of dependency conflicts is a more robust and secure approach. If this workaround is necessary, document it clearly and test thoroughly to mitigate risks.
npm shows typescript as 'undefined' during peer dep resolution, causing ERESOLVE failures across packages. Adding legacy-peer-deps=true to .npmrc bypasses strict peer checking.