diff --git a/code/lib/cli/src/js-package-manager/NPMProxy.test.ts b/code/lib/cli/src/js-package-manager/NPMProxy.test.ts index 64ccc474802c..4de3a35fed6d 100644 --- a/code/lib/cli/src/js-package-manager/NPMProxy.test.ts +++ b/code/lib/cli/src/js-package-manager/NPMProxy.test.ts @@ -47,16 +47,12 @@ describe('NPM Proxy', () => { }); }); describe('npm7', () => { - it('should run `npm install --legacy-peer-deps`', () => { + it('should run `npm install`', () => { const executeCommandSpy = jest.spyOn(npmProxy, 'executeCommand').mockReturnValue('7.1.0'); npmProxy.installDependencies(); - expect(executeCommandSpy).toHaveBeenLastCalledWith( - 'npm', - ['install', '--legacy-peer-deps'], - expect.any(String) - ); + expect(executeCommandSpy).toHaveBeenLastCalledWith('npm', ['install'], expect.any(String)); }); }); }); @@ -83,7 +79,7 @@ describe('NPM Proxy', () => { expect(executeCommandSpy).toHaveBeenLastCalledWith( 'npm', - ['install', '--legacy-peer-deps', '-D', '@storybook/preview-api'], + ['install', '-D', '@storybook/preview-api'], expect.any(String) ); }); @@ -112,7 +108,7 @@ describe('NPM Proxy', () => { expect(executeCommandSpy).toHaveBeenLastCalledWith( 'npm', - ['uninstall', '--legacy-peer-deps', '@storybook/preview-api'], + ['uninstall', '@storybook/preview-api'], expect.any(String) ); }); diff --git a/code/lib/cli/src/js-package-manager/NPMProxy.ts b/code/lib/cli/src/js-package-manager/NPMProxy.ts index 06f17e462198..515e254a2ad6 100644 --- a/code/lib/cli/src/js-package-manager/NPMProxy.ts +++ b/code/lib/cli/src/js-package-manager/NPMProxy.ts @@ -1,5 +1,3 @@ -import semver from 'semver'; - import { JsPackageManager } from './JsPackageManager'; import type { PackageJson } from './PackageJson'; @@ -26,38 +24,16 @@ export class NPMProxy extends JsPackageManager { return this.executeCommand('npm', ['--version']); } - hasLegacyPeerDeps() { - const result = this.executeCommand('npm', [ - 'config', - 'get', - 'legacy-peer-deps', - '--location=project', - ]); - return result.trim() === 'true'; - } - - setLegacyPeerDeps() { - this.executeCommand('npm', ['config', 'set', 'legacy-peer-deps=true', '--location=project']); - } - - needsLegacyPeerDeps(version: string) { - return semver.gte(version, '7.0.0') && !this.hasLegacyPeerDeps(); - } - getInstallArgs(): string[] { if (!this.installArgs) { - this.installArgs = this.needsLegacyPeerDeps(this.getNpmVersion()) - ? ['install', '--legacy-peer-deps'] - : ['install']; + this.installArgs = ['install']; } return this.installArgs; } getUninstallArgs(): string[] { if (!this.uninstallArgs) { - this.uninstallArgs = this.needsLegacyPeerDeps(this.getNpmVersion()) - ? ['uninstall', '--legacy-peer-deps'] - : ['uninstall']; + this.uninstallArgs = ['uninstall']; } return this.uninstallArgs; }