-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Parcel wipes out Package.json when installing dependencies #7271
Comments
Parcel doesn't edit package.json, it just runs a package manager like yarn or npm, which may edit the package.json to add the dependency. Not sure what would be causing it to be removed completely. Could you provide more details? Are you using Yarn or NPM? What versions? Are you in a monorepo? What directory are you running Parcel from? Is it the project root with the package.json/lockfile, a sub directory, or outside? This sounds similar to #2978, which I thought was fixed, but maybe there's another case. |
Btw you can run with the |
Thanks Devon, I'm running it from the root directory where the package.json is, npm 7.15.1, node 16.3, no monorepo. running it with --no-autoinstall and @parcel/transformer-stylus installed, gives me this error:
|
Hmm strange. So I made a example project with these files: package.json: {
"name": "test",
"scripts": {
"build": "parcel build test.styl"
},
"dependencies": {
"parcel": "^2.0.1"
}
} test.styl: .foo
background: red I first ran Is there some other possible way to reproduce or some other detail of your setup that I missed? Maybe you have a package.json in a parent directory or something that is causing npm to be confused? Maybe some kind of symlink? I'm kinda grasping at straws here... It seems Parcel cannot find |
@devongovett I'm able to replicate it here: https://github.com/wesbos/parcel-issue-replication |
Hmm, it works for me... 😅 Let me ask and see if anyone else on the core team can reproduce. Does it change if you clone that repo into a different directory? I'm wondering if something in a parent directory of your project is causing a problem somehow... |
Shoot eh. I tried it in the very root of my computer, same issue. I do get this error, could it be related?
Here is a video of me having the issue: https://share.getcloudapp.com/4guPZ1Om |
@wesbos FWIW, the repro repo works for me (clone, install, run, w/ no deleted Do you have any custom npm config or something crazy in your |
GOT IT! I had a rouge package-lock.json file in my computers root directory. It didn't have anything to do with parcel in it, but it was causing it. Ugh, thank you for your help. you were right with the parent files. |
Ah nice. I can reproduce if I add a |
This exact issue is happening to me.
I am using |
I battled a similar issue for the past two days with the following error:
As in the @asanteb case, it worked fine on my local machine but failed inside a Jenkin's job. Node version: v14.17.0 |
Also had similar issue! Deleted Thank you for figuring it out guys! |
`@parcel/core: Cannot find Parcel plugin "@parcel/transformer-typescript-types" ......../node_modules/@parcel/config-default/index.json:4:26
In my case I am adding the --no-autoinstall option, the transformer library is installed and, even though, I am having this issue. If I remove the option, no matter if the transformer library is installed or not, Parcel tries to install it and remove my package.json. macOS Monterey. I am using Azure as artifact repo so I have a .npmrc file pointing to two Azure artifacts repos. |
I had a |
I can confirm that this solution worked for me. There was a Very strange and not idea at all. I guess it shouldn't be even looking outside its own route directory, that's madness. Any way to force it to only look for local installed dependencies instead of recursively searching upwards? This file was not in the parent and actually 3 levels up. |
Came to also confirm, Thanks to wesbos for finding the root cause :
Deleting package.json in the parent directory resolved the issue |
I faced this issue with yarn 1 on Windows 10. My solution was to update yarn to version 3 and delete any package.json, package-lock.json and yarn.lock file located in the user folder (C:\Users\YourProfileName) |
Not quite sure how this is related, but deleting a My best guess is that a lock file higher up the file tree puts Parcel into some kind of undefined state, where all kinds of things act strangely? Not sure. But this could be related to a lot of "weird behavior" issues (and solve more than this one error behavior) 🤔 . |
Thanks @pklaschka. Also for me this was caused by a packge-lock.json file in a directory somewhere up in the tree. |
I was having troubles getting a project I cloned to work: 🚨 Build failed.
@parcel/core: Cannot find Parcel plugin "@parcel/transformer-sass"
/home/crypticspaghetti/Code/github/crypticspaghetti/simplefolio/node_modules/@parcel/config-default/index.json:25:23
24 | "*.{styl,stylus}": ["@parcel/transformer-stylus"],
> 25 | "*.{sass,scss}": ["@parcel/transformer-sass"],
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Cannot find module "@parcel/transformer-sass" The module in question was installed already so it had me scratching my head for a while. The comments in this issue pointed me in the right direction. Mine was related to a rogue |
Yep, confirmed it was a rogue package.json. Four levels up. What in the world. |
I have same issue, when pnpm install in root of monorepos project |
I have the same issue as @yami-shiftasia, for us this is causing parcel to somehow not detect our
We confirmed this by putting random invalid text into the We are unable to reproduce this in a non-monorepo environment however, from what we've found it appears as if parcel is running in the root of the monorepo and not in |
thank for keeping our bot overlords at bay |
Just lost a bunch of work I did on my package.json.
I am running parcel 2.0.1, which was released yesterday to fix an issue with dependencies not being installed.
I have targets in my package.json like this:
When I run
parcel
, it saysInstalling @parcel/transformer-stylus...
Then it both wipes out everything in my
node_modules
directory, and wipes out everything in my package.json and replaces it with:Probably something to do with the new way you are saving deps?
Pre-installing
@parcel/transformer-stylus
does not fix it either, same thing.I assume this is also happening with sass and other transformers
The text was updated successfully, but these errors were encountered: