MCPcopy
hub / github.com/vercel/next.js / uninstallPackage

Function uninstallPackage

packages/next-codemod/lib/handle-package.ts:41–64  ·  view source on GitHub ↗
(
  packageToUninstall: string,
  pkgManager?: PackageManager
)

Source from the content-addressed store, hash-verified

39}
40
41export function uninstallPackage(
42 packageToUninstall: string,
43 pkgManager?: PackageManager
44) {
45 pkgManager ??= getPkgManager(process.cwd())
46 if (!pkgManager) throw new Error('Failed to find package manager')
47
48 let command = 'uninstall'
49 if (pkgManager === 'yarn') {
50 command = 'remove'
51 }
52
53 try {
54 execa.sync(pkgManager, [command, packageToUninstall], {
55 stdio: 'inherit',
56 shell: true,
57 })
58 } catch (error) {
59 throw new Error(
60 `Failed to uninstall "${packageToUninstall}". Please uninstall it manually.`,
61 { cause: error }
62 )
63 }
64}
65
66const ADD_CMD_FLAG = {
67 npm: 'install',

Callers 1

runTransformFunction · 0.90

Calls 1

getPkgManagerFunction · 0.70

Tested by

no test coverage detected