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

[BUG] npm install can potentially delete .git directory #1641

Closed
MylesBorins opened this issue Aug 7, 2020 · 6 comments
Closed

[BUG] npm install can potentially delete .git directory #1641

MylesBorins opened this issue Aug 7, 2020 · 6 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release

Comments

@MylesBorins
Copy link
Contributor

This behavior is only reproducible with a specific version of resolve, but it is only reproducible on npm 7. I'm pretty sure the deletion of the .git folder is an unfortunate side effect of a missing dependency causing unexpected behavior in safe-publish-latest. This behavior is happening independent of --legacy-peer-deps

Current Behavior:

npm install fails with the error Error: Cannot find module 'camelcase', bails, and the .git folder is deleted

Expected Behavior:

Modules to be installed and .git folder to not be affected.

Steps To Reproduce:

This will permanently damage the repo so please do it in a fresh install

$ git clone https://github.com/browserify/resolve.git
$ cd resolve
$ git checkout v1.17.0
$ npm install

Environment:

OSX 10.15.6
Node.js v14.6.0
npm v7.0.0-beta.2

@MylesBorins MylesBorins added Release 7.x work is associated with a specific npm 7 release Bug thing that needs fixing Needs Triage needs review for next steps labels Aug 7, 2020
@ljharb
Copy link
Contributor

ljharb commented Aug 7, 2020

for the record, safe-publish-latest has a dep on yargs 7, which depends on camelcase.

@MylesBorins
Copy link
Contributor Author

A couple notes before I vanish for the weekend. This bug is unrelated to any of the scripts being run by the package and with a bit of poking I've managed to find even stranger behavior... npm seems to be bringing folder back FROM THE DEAD

$ git clone https://github.com/browserify/resolve.git
$ cd resolve
$ git checkout v1.17.0
$ rm -rf .git
$ rm -rf test/
$ rm -rf examples/
$ git init
$ git add .
$ git commit -m "Seriously wat"
$ npm install

You will notice that not only is the .git folder blown away, but test/ and examples/ is restored... something I can't for the life of me figure out how or why is happening.

@isaacs
Copy link
Contributor

isaacs commented Aug 9, 2020

Ooh, this is a fun one. Note that it only happens if the folder is named resolve.

For some reason, it's trying to reify the published resolve version over the root node of the project. That's not supposed to happen :)

isaacs added a commit to npm/arborist that referenced this issue Aug 10, 2020
@isaacs
Copy link
Contributor

isaacs commented Aug 10, 2020

Root cause: npm/arborist@909651d

isaacs added a commit that referenced this issue Aug 10, 2020
@isaacs
Copy link
Contributor

isaacs commented Aug 10, 2020

Fixed in beta branch. 5fb2177

@isaacs isaacs closed this as completed Aug 10, 2020
@hthetiot
Copy link

hthetiot commented Jul 7, 2022

It occurred to one of my developer on node 16.14.2 and npm 8.5.0.
We are investigating to reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

4 participants