parcel: Regression: `Uncaught error: Cannot find module`
I’m sorry for submitting such a general report without a small repro case. But this bug has already cost me a lot of time, and I’m very much at a loss for how to deal with it. I thought I’d file what I could, though.
🐛 bug report
Check out the following:
- Repo: https://github.com/cubing/cubing.js
- Commit: 3ff0968e92a46d14c2a1dad4f18080b6313f3949
Run:
npm install
make clean dev
Then visit http://localhost:3333/twisty/twisty-player.html and check the browser console.
See https://www.youtube.com/watch?v=PXkfFrLHS6o for an example of a successful build (beginning of video) and 8:32 for a failure.
To avoid the behaviour:
npm install parcel@2.0.0-nightly.481 # no bug
rm -rf ./node_modules/ ; npm install; make clean dev
To cause the behaviour (sometimes):
npm install parcel@2.0.0-nightly.485 # bug
rm -rf ./node_modules/ ; npm install; make clean dev
(Parcel nightly versions 482/483/484 do not exist.)
🤔 Expected Behavior
No error. The page loads, shows a Rubik’s Cube, and a table for some options.
😯 Current Behavior
Sometimes (the vast majority of the time, maybe 90%?) after running npm install from scratch, the following error appears:
Uncaught Error: Cannot file module '2du48'.
This seems to correspond to ./dom/viewers/Twisty3DCanvas. It seems clear that there’s an issue with the loading graph somehow related to this file, starting in parcel@2.0.0-nightly.485.
See https://garron.net/temp/cubing-js-parcel-2021-01-18.zip for the state of the cache folder when this occurs.
Sometimes after running npm install (maybe 10% of the time?), however, there is no error. As far as I can tell, the error doesn’t occur until the next time I delete node_modules and run npm install from scratch, which rolls the dice again.
💁 Possible Solution
No idea, I’m sorry. I’ve tried to dig into stack traces, but something is going wrong deep inside Parcel’s module loading code and I can’t debug it from inside my code.
I can’t figure out how to map Parcel nightlies to Git commits, but correlating the version dates at https://www.npmjs.com/package/parcel with https://github.com/parcel-bundler/parcel/commits/v2?after=bdc45e49437b986934d3b1b0d8f6a4ecc292a2aa+34&branch=v2 suggests that this regression was introduced in this range:
🔦 Context
I was trying to debug a Parcel bug that is breaking our production build. I tried to update Parcel to the latest nightly 2.0.0-nightly.539 and was able to observe a bug in dev. After spending over 24 hours, I finally concluded that our production bug is not the same as the bug that was caused by upgrading to 2.0.0-nightly.539. I’m going to downgrade for now in order to debug the other issue, but I’ve filed this issue to document the one that happened due to the upgrade.
💻 Code Sample
See above.
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | parcel@2.0.0-nightly.485 and above (I bisected. 481 and lower do not exhibit this issue, 482/483/484 do not exist, 485 and above do exhibit the issue).) |
| Node | v15.4.0 |
| npm/Yarn | 6.14.11 |
| Operating System | macOS 10.15.7 as well as Big Sur (I can repro this issue on two different computers) |
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 3
- Comments: 30 (7 by maintainers)
Commits related to this issue
- Revert "[package.json] Update `parcel` to the latest nightly." This reverts commit 4d2185f476ace6afa2e6f3759a526147715a8728. This temporarily works avoids https://github.com/parcel-bundler/parcel/is... — committed to cubing/cubing.js by lgarron 3 years ago
- [package.json] Clean everything before `make dev`. We're running into certain Parcel issues way too much right now. Some subset of these: https://github.com/parcel-bundler/parcel/issues/5683 https://... — committed to cubing/cubing.js by lgarron 3 years ago
- [package.json] Clean everything before `make dev`. We're running into certain Parcel issues way too much right now. Some subset of these: https://github.com/parcel-bundler/parcel/issues/5683 https://... — committed to cubing/cubing.js by lgarron 3 years ago
- [demo] Avoid impoorting `twisty` directly from HTML. This is supposed to be fine, but regularly breaks development due to https://github.com/parcel-bundler/parcel/issues/5683#issuecomment-766450652 — committed to cubing/cubing.js by lgarron 3 years ago
- [twizzle/edit] Use an async import for the 2x2x2 def. Parcel breaks if we use a sync import, because `cubing/puzzles` imports the same file async. This may be related to: https://github.com/parcel-bu... — committed to cubing/cubing.js by lgarron 3 years ago
- [twizzle/edit] Use an async import for the 2x2x2 def. Parcel breaks if we use a sync import, because `cubing/puzzles` imports the same file async. This may be related to: https://github.com/parcel-bu... — committed to cubing/cubing.js by lgarron 3 years ago
- [experiments] Remove workarounds for Parcel's bug with reused entry files. https://github.com/parcel-bundler/parcel/issues/5683#issuecomment-766450652 — committed to cubing/cubing.js by lgarron 2 years ago
- * Switched to parcel's experimental bundler, to fix the bug it (sometimes) has where it "misses" the import of the "AppSpecific.ts" file in "MyStartupTweaks.ts". (well, it keeps the "require(...)" lin... — committed to Venryx/w-okada-voice-changer-scripts by Venryx 5 months ago
I am having the same issue with
Cannot find module xxx, which corresponds to"@parcel/transformer-js/src/esmodule-helpers.js"parcel 2.0.0 npm 8.1.0 node 16.13.0 macOS 11.6 Safari 15.0 (16612.1.29.41.4, 16612)
I have the same problem.
Changing this in my entry
index.htmlfixed it for me. Weird that I had no issues on 2.0.1.I just updated to Parcel 2.0.1 and still having the same issue. Is this a configuration option problem in our stack or is this a bug in Parcel?
I believe my issue is related (if not duplicate). I’m happy to say I made a repro repo and also I found a workaround for all affected: bundler-experimental seems to be free of this bug.
Issue with repro repo: https://github.com/parcel-bundler/parcel/issues/8480
Workaround
.parcelrc:Also hitting this on 2.3.2. Some level of complexity in the bundle graph seems to trigger it. The missing bundle is being generated, but the underlying js file is not being loaded client side. Tried fixing by removing scope hoisting and source mapping, but no luck.
Only occurs in
build, notwatch, since it’s related to code splitting.@Aloento In my case I am using bootstrap.
If I do:
in this order, I get this strange error. But, if I change the imports order to:
(bootstrap first), the error is gone!
I have an even simpler repro: https://github.com/yume-chan/parcel-repro-5683
a.jsandb.jseach imports a different image file, so they are completely unrelated. When I includea.jsbeforeb.jsinindex.html, it works, then change the order, cannot find module.It’s related to build cache. If I clean the build cache, I can get the reversed behavior.
I’m also experiencing the same issue and updating parcel to 2.0.1 didn’t solve it.
parcel: 2.0.0-nightly.776
I’ve bisected the commits, this is a regression of https://github.com/parcel-bundler/parcel/pull/5200.
Happens consistently for me with the minimal reproduction: https://github.com/mischnic/parcel-issue-5683
For
dist/a.html, the script tags for the shared bundles are added in the wrong order.The hash is appended to the version field in the published tarball, you can see that for example here: https://unpkg.com/browse/parcel@2.0.0-nightly.447/package.json