denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
96.84k stars 5.35k forks source link

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

Open kuchta opened 1 week ago

kuchta commented 1 week ago

Version: Deno 2.0.0

littledivy commented 1 week ago

Do you have a reproduction?

kuchta commented 1 week ago

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:daisyui@5.0.0-alpha.14
: deno remove daisyui
Removed daisyui
satyarohith commented 1 week ago

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
bartlomieju commented 1 hour ago

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

dsherret commented 1 hour ago

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.