FredKSchott / snowpack

ESM-powered frontend build tool. Instant, lightweight, unbundled development. ✌️
https://www.snowpack.dev
MIT License
19.48k stars 922 forks source link

🐛 BUG: Wrong versions of packages in build cache leading to build failures #3785

Open aventide opened 3 years ago

aventide commented 3 years ago

Quick checklist

What package manager are you using?

npm node 16.12.0

What operating system are you using?

macOS

Describe the bug

When trying to do a React project build with snowpack, I get a build failure when I attempt to import and render any components from @inlet/react-pixi.

[23:30:24] [snowpack] ENOENT: no such file or directory, open '/Users/alex/Dev/octagon-board-test/node_modules/.cache/snowpack/build/eventemitter3@4.0.7/eventemitter3.js'

When inspecting the .cache/snowpack/build directory, I see a directory named eventemitter3@3.1.2

When attempting to manually edit the directory name to force a match, I then get a similar problem with the version of punycode, and manually editing the name doesn't get me anywhere. At this point, I'm not sure why the build cache versions aren't matching what's expected by snowpack.

I will update with an example if it turns out this is an interesting problem and not me being dumb somehow. But following my instruction should get you an example pretty quickly.

Thanks for any advice on this!

Steps to reproduce

  1. Follow the snowpack react tutorial (https://www.snowpack.dev/tutorials/react) to get a skeleton project that can render a React component.

  2. In the root component (say, App.js), use this code:

    
    import React from 'react';
    import { Stage, Sprite } from '@inlet/react-pixi';

export default function App() { return

</Stage>

};



3. Run `npm start`

Note: react-pixi works fine in create-react-app, which leads me to believe it's a snowpack issue.

### Link to minimal reproducible example (optional)

_No response_
alexbepple commented 3 years ago

Can you reproduce the issue with yarn?

Reason why I am asking: I am seeing a similar issue with react-redux, which goes away, if I use yarn instead of npm.

With npm I am seeing:

Error: ENOENT: no such file or directory, open '…/node_modules/.cache/snowpack/build/react-is@17.0.2/react-is.js'

react-redux@7.2.6 depends both directly and transitively on react-is:

react-redux@7.2.6 → react-is@17.0.2 react-redux@7.2.6 → prop-types@15.7.2 → react-is@16.13.1

NPM installs react-is@16.13.1 into node_modules/prop-types/node_modules/react-is and react-is@17.0.2 into node_modules/react-is

While Yarn does it the other way around: react-is@16.13.1 into node_modules/react-is and react-is@17.0.2 into node_modules/react-redux/node_modules/react-is

My understanding is that both version resolutions are compliant with the spec. Assuming that this is the same issue, I would tend to agree that this is a Snowpack issue.

alexbepple commented 3 years ago

possible duplicate: #3743

lawell-wilhelm commented 2 years ago

I got a similar issue when attempting to import useSelector and useDispatch from react-redux. I followed @alexbepple first suggestion, that of using yarn instead of npm, and it fixed the issue. Thanks

takerukoushirou commented 2 years ago

Can confirm the same issue with only pixi.js as the sole dependency using NPM when restarting snowpack dev. Downgraded to 3.8.6 and issue disappears.

ambastos commented 2 years ago

Can confirm the same issue with only pixi.js as the sole dependency using NPM when restarting snowpack dev. Downgraded to 3.8.6 and issue disappears.

Works for me!