Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rimraf node_modules delete all files #259

Closed
xiaoxue1341 opened this issue Mar 3, 2023 · 11 comments
Closed

rimraf node_modules delete all files #259

xiaoxue1341 opened this issue Mar 3, 2023 · 11 comments

Comments

@xiaoxue1341
Copy link

I have a monorepo warehouse. When I delete node at the outermost layer_ Modules folder, the files in each folder under packages are also deleted
image

@isaacs
Copy link
Owner

isaacs commented Mar 3, 2023

That definitely shouldn't happen. What command are you running?

@edw1882
Copy link

edw1882 commented Mar 3, 2023

Something like this I suspect

rimraf --glob node_modules */node_modules

It removes the contents of the folders that contain a node_modules folder as well

@isaacs
Copy link
Owner

isaacs commented Mar 3, 2023

Yeah, but have you tested that? Because that is not what I'm seeing.

#!/bin/bash

rm -rf test-gh-259
mkdir test-gh-259
cd test-gh-259
mkdir -p node_modules/{a,b,c}
touch node_modules/{a,b,c}/{index.js,package.json}
mkdir -p packages/{x,y,z}/node_modules/{i,j,k}
touch packages/{x,y,z}/{node_modules/{i,j,k}/,}{index.js,package.json}
ln -s ../packages/x node_modules/x
ln -s ../packages/y node_modules/y
ln -s ../packages/z node_modules/z
ln -s ../x packages/y/node_modules/x
ln -s ../x packages/z/node_modules/x
ln -s ../y packages/x/node_modules/y
ln -s ../y packages/z/node_modules/y
ln -s ../z packages/x/node_modules/z
ln -s ../z packages/y/node_modules/z

tree
npx -y rimraf@latest --glob "node_modules" "packages/*/node_modules"
tree

Output:

.
├── node_modules
│   ├── a
│   │   ├── index.js
│   │   └── package.json
│   ├── b
│   │   ├── index.js
│   │   └── package.json
│   ├── c
│   │   ├── index.js
│   │   └── package.json
│   ├── x -> ../packages/x
│   ├── y -> ../packages/y
│   └── z -> ../packages/z
└── packages
    ├── x
    │   ├── index.js
    │   ├── node_modules
    │   │   ├── i
    │   │   │   ├── index.js
    │   │   │   └── package.json
    │   │   ├── j
    │   │   │   ├── index.js
    │   │   │   └── package.json
    │   │   ├── k
    │   │   │   ├── index.js
    │   │   │   └── package.json
    │   │   ├── y -> ../y
    │   │   └── z -> ../z
    │   └── package.json
    ├── y
    │   ├── index.js
    │   ├── node_modules
    │   │   ├── i
    │   │   │   ├── index.js
    │   │   │   └── package.json
    │   │   ├── j
    │   │   │   ├── index.js
    │   │   │   └── package.json
    │   │   ├── k
    │   │   │   ├── index.js
    │   │   │   └── package.json
    │   │   ├── x -> ../x
    │   │   └── z -> ../z
    │   └── package.json
    └── z
        ├── index.js
        ├── node_modules
        │   ├── i
        │   │   ├── index.js
        │   │   └── package.json
        │   ├── j
        │   │   ├── index.js
        │   │   └── package.json
        │   ├── k
        │   │   ├── index.js
        │   │   └── package.json
        │   ├── x -> ../x
        │   └── y -> ../y
        └── package.json

23 directories, 36 files
.
└── packages
    ├── x
    │   ├── index.js
    │   └── package.json
    ├── y
    │   ├── index.js
    │   └── package.json
    └── z
        ├── index.js
        └── package.json

4 directories, 6 files

@isaacs
Copy link
Owner

isaacs commented Mar 3, 2023

It's just deleting the node_modules folders, not the package contents themselves.

@isaacs
Copy link
Owner

isaacs commented Mar 3, 2023

Replacing the rimraf command with npx -y rimraf@latest --glob '**/node_modules' has the same effect. Removes node_modules, not the package source contents.

@isaacs
Copy link
Owner

isaacs commented Mar 4, 2023

Will re-open if reproduction case is provided.

@isaacs isaacs closed this as completed Mar 4, 2023
@xiaoxue1341
Copy link
Author

ypLive-Visual-Studio-Code-2023-0.mp4

You can see this video. All the files in liveRoom2 have been deleted. The file change area on the left shows the deleted 3k+files

@isaacs
Copy link
Owner

isaacs commented Mar 6, 2023

The video is not loading. Please share what command you ran. Just comment as text, not a video or screenshot.

@edw1882
Copy link

edw1882 commented Mar 6, 2023

He's on windows and running

rimraf node_modules

It is deleting ALL the files in a folder further down the tree that happens to have a node_modules folder.

@isaacs
Copy link
Owner

isaacs commented Mar 6, 2023

Ah, I think I see what's going on. Symlinks aren't being handled properly in the windows version. Will fix shortly.

@isaacs isaacs reopened this Mar 6, 2023
@isaacs isaacs closed this as completed in cd6fbc6 Mar 6, 2023
@isaacs
Copy link
Owner

isaacs commented Mar 6, 2023

Fixed on 4.3.1. It could also have affected posix systems, so this is potentially serious. Thanks for reporting it.

brxken128 added a commit to spacedriveapp/spacedrive that referenced this issue May 21, 2023
github-merge-queue bot pushed a commit to spacedriveapp/spacedrive that referenced this issue May 30, 2023
* log to disk

* remove some unwraps

* panicless

* some p2p error handling

* clippy moment

* Fix `<ErrorBoundary />`

* open logs button

* 39 to 0

* fix types

* update deps and comment out broken tests

* clippy

* more clippy

* upgrade rimraf - isaacs/rimraf#259

* regen broken lockfile

* update `notify` and update `commands.ts`

* more clippy (pls work)

* allow deprecated for p2p (hopefully temporary)

* a

* upgrade deps for p2p

* do betterer

* do it correctly

* remove unused import

* improve core startup error + bc keypair

---------

Co-authored-by: Utku Bakir <[email protected]>
Co-authored-by: brxken128 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants