parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.44k stars 2.27k forks source link

Error installing cssnano + wipes package.json #4568

Closed LukeTOBrien closed 4 years ago

LukeTOBrien commented 4 years ago

🐛 bug report

I just did parcel build on a new project (a new project meaning Parcel will auto install what it comes across)
I got the following error and then my package.json was wiped, everything gone:

npm WARN nano-css@5.3.0 requires a peer of react@ but none is installed. You must install peer dependencies yourself. npm WARN nano-css@5.3.0 requires a peer of react-dom@ but none is installed. You must install peer dependencies yourself. npm WARN static@1.0.0 No repository field. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.12 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.12: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

I do not want to use react in my project, it is a simple TypeScript project.
I am also confussed between nano-css and cssnano.
Nano-css is css-in-js, I am building a plain index.html with css in my <link>, is seem Pacrel thinks that I need js-css when I do not.

When I run it again: 'parcel' is not recognized as an internal or external command.
It doesn't clear every node_module, just most of them.
So I have to wait x no of minutes to install packages.

🤔 Expected Behavior

Work like it always used to and does on other progects.

😯 Current Behavior

As above.

In any case, an error should not make Parcel wipe clean the packages.json and the node_modules

💁 Possible Solution

Use a different version of cssnsno or not at all.

I have imported the offending css file in my main styles.less <- This worked

mischnic commented 4 years ago

Use a different version of cssnano or not at all.

Parcel doesn't use/install nano-css.

I have imported the offending css file in my main styles.less <- This worked

Please provide more details.

LukeTOBrien commented 4 years ago

Thanks,

I am going to close this issue now because I have it working.

In my index.html I hade a long CSS href path:

<link href="../UI/Packages/radzen.blazor/2.6.6/staticwebassets/css/default-base.css" rel="stylesheet" />

When I did barcel build I got the above error.
Importing the CSS into my main less file solved it:

@import (less) "../../UI/Packages/radzen.blazor/2.6.6/staticwebassets/css/default-base.css";

Parcel doesn't use/install nano-css.

Then how did I get the error to do with nano-css?

The whole thing is a most complexing mystery... but I am statisfied that I have the thing working now.