deno icon indicating copy to clipboard operation
deno copied to clipboard

`deno remove` doesn't remove the package from node_modules folder

Open kuchta opened this issue 1 year ago • 5 comments

Version: Deno 2.0.0

kuchta avatar Oct 16 '24 11:10 kuchta

Do you have a reproduction?

littledivy avatar Oct 16 '24 17:10 littledivy

Sure, it's easily reproducible, since it probably happens in all projects using node-modules-dir.

: deno run -A npm:create-vite@latest
✔ Project name: … vite-project
✔ Select a framework: › React
✔ Select a variant: › TypeScript

Scaffolding project in /Users/kuchta/Projects/vite-project...

Done. Now run:

  cd vite-project
  npm install
  npm run dev

: cd vite-project/
: deno install
: deno add -D npm:daisyui@alpha
Add npm:[email protected]
: deno remove daisyui
Removed daisyui

kuchta avatar Oct 16 '24 18:10 kuchta

For reference: npm rm <package> removes the package (and its deps) from node_modules folder.

➜  26301 npm i express

added 65 packages in 2s

13 packages are looking for funding
  run `npm fund` for details
➜  26301 la node_modules
total 56
...
drwxr-xr-x   8 sr  staff   256B Oct 17 01:20 express
...

➜  26301 cat package.json
{
  "dependencies": {
    "express": "^4.21.1"
  }
}
➜  26301 npm rm express

removed 65 packages, and audited 1 package in 242ms

found 0 vulnerabilities

➜  26301 la node_modules
total 8
drwxr-xr-x  2 sr  staff    64B Oct 17 01:20 .bin
-rw-r--r--  1 sr  staff    84B Oct 17 01:20 .package-lock.json

satyarohith avatar Oct 16 '24 19:10 satyarohith

This one could be fixed easily, by removing contents of node_modules/ and running "top-level install" again.

bartlomieju avatar Oct 24 '24 15:10 bartlomieju

An issue with that is it needs to run post install scripts again. It might be better to just do a diff of the snapshot for which packages get removed.

dsherret avatar Oct 24 '24 15:10 dsherret