-
-
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
Regression: Uncaught error: Cannot find module
#5683
Comments
This reverts commit 4d2185f. This temporarily works avoids parcel-bundler/parcel#5683 while we try to see if there is a reasonable workaround for parcel-bundler/parcel#4389 .
Happens consistently for me with the minimal reproduction: https://github.com/mischnic/parcel-issue-5683 For
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 |
I've bisected the commits, this is a regression of #5200. |
A workaround is not using a file that is imported in some other place as a So instead of this https://github.com/cubing/cubing.js/blob/afa6e5b9379e8b9549769ec0cea4615a87c80a73/src/demo/twisty/2d-ll-stickering.html#L7 |
Thanks, that's very helpful! |
Would this have a similar effect for global variables such as |
We're running into certain Parcel issues way too much right now. Some subset of these: parcel-bundler/parcel#5683 parcel-bundler/parcel#4195 https://github.com/parcel-bundler/`.
We're running into certain Parcel issues way too much right now. Some subset of these: parcel-bundler/parcel#5683 parcel-bundler/parcel#4195 https://github.com/parcel-bundler/`.
This is supposed to be fine, but regularly breaks development due to parcel-bundler/parcel#5683 (comment)
I've tried converting our project back to the Parcel v2 release candidate, and an error with this symptom ended up being a blocking issue again. :-/
|
After some investigation, this seems to be the issue described in #4095 The same file was imported sync in one place and async in the other place, causing the sync import to break as described above. In this case, it's easy to switch the sync import to something else, but I'm rather sad that I'm already running into this issue again. 😭 |
Parcel breaks if we use a sync import, because `cubing/puzzles` imports the same file async. This may be related to: parcel-bundler/parcel#5683 parcel-bundler/parcel#4095
Parcel breaks if we use a sync import, because `cubing/puzzles` imports the same file async. This may be related to: parcel-bundler/parcel#5683 parcel-bundler/parcel#4095
That bug should be fixed though |
@mischnic This is a consistent repro for me:
This is with Parcel 2.0.0-rc.0. :-( npm 7.21.0 |
I am having the same issue with parcel 2.0.0 |
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'm also experiencing the same issue and updating parcel to 2.0.1 didn't solve it. parcel: 2.0.0-nightly.776 |
I have an even simpler repro: https://github.com/yume-chan/parcel-repro-5683
It's related to build cache. If I clean the build cache, I can get the reversed behavior. |
I think I'm suffering from a similar issue but not exactly this? On This issue is older than 2.0.1 so I guess it's something else. Will check if it's maybe cyclic imports… |
Changing this in my entry diff --git a/app/public/index.html b/app/public/index.html
index 2b0e175da..1efda18df 100644
--- a/app/public/index.html
+++ b/app/public/index.html
@@ -47,6 +47,8 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
- <script src="../src/index.tsx" type="module"></script>
+ <script type="module">
+ import "../src/index.tsx";
+ </script>
</body>
</html> |
When changing the build target to Cleaning build cache doesn't work. |
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 |
The underlying cause for us here appears to be related to the pragmaFrag However, as soon as there is a tree with some mixture of frag and no frag, the above error occurs. Explicitly adding the frag to the component(s) missing it in the chain, even if they don't themselves use the Not enough time to come up with a minimal reproduction right now, but hopefully this is helpful to some of those hitting this bug and to the authors. |
I have the same problem.
|
I had a similar error, after further debugging it seemed that I wasn't invoking the imported javascript function synchronously. import '/src/scripts/myLib.ts'
window.myLib.init() // Causes the cannot find module error The fix in my case was to call the init() func of myLib synchronously Changed it to: import('/src/scripts/myLib.ts').then(() => window.myLib.init()) and the error disappeared. Using Parcel v2.4.0 The error reporting isn't so verbose, it can be that the fix is different in other cases. This was mine ☝️ PS: The above fix will change the script import from inline to dynamic. If you want to still keep the script inline, invoke init() function inside the myLib.ts instead |
If Hot Module Reloading is not working, the problem may relate to the periods ( Consider changing the import App from "./App";
import App from "/src/App" |
any updates? |
Works for me too... really strange behavior! |
@Aloento In my case I am using bootstrap. If I do: <body>
<script type="module" src="../js/scripts/home.js"></script>
<script type="module" src="../js/vendors/bootstrap.js"></script>
</body> in this order, I get this strange error. But, if I change the imports order to: <body>
<script type="module" src="../js/vendors/bootstrap.js"></script>
<script type="module" src="../js/scripts/home.js"></script>
</body> (bootstrap first), the error is gone! |
I observe similar issues with quite random "cannot find module", depending on a setup it affects different imports. Only on production builds. I'm trying to make a repro repo and so far no luck finding what could be a reason. Only happens so far on our most complex mono repo. |
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: #8480 Workaround {
"extends": "@parcel/config-default",
"bundler": "@parcel/bundler-experimental"
}
|
I have the same error. On the console, I see a bunch of warnings like these: @parcel/transformer-js: Conditional or non-top-level `require()` call. This causes the resolved module and all dependencies to be wrapped.
@parcel/transformer-js: Unknown usage of CommonJS `module` object. This causes the module to be wrapped, and tree shaking to be disabled. However, I do not have any conditional dependencies. Also, the "CommonJS My stack uses:
This solution worked for me: #5683 (comment) |
I have encountered this error also. I have a (AFAIK) straightforward repo and dev setup, purely for messing around with React and Node/TS. When I try For the dev build it throws the following:
from this code:
bundled from this src:
For the release build it throws the following:
from this code: Here is the package.json
if i am using Parcel (or something else) incorrectly please let me know. I've followed the Parcel docs and i expect it to work OOTB as it is touted as doing. Going to try a different bundler instead. |
We are giving this a try now - given this can be an intermittent issue we need to keep an eye on it, but the change didn't break anything and our previously failing deployment has worked. Thanks so much for posting this - I'm hopeful it'll help us get past this problem at least until root cause is sorted. |
Sadly this has ended up being an incorrect statement. We've seen that images loaded using This is still a smaller problem than the main one, but definitely something to test if you use the workaround. |
…imes) has where it "misses" the import of the "AppSpecific.ts" file in "MyStartupTweaks.ts". (well, it keeps the "require(...)" line, but omits the mapping entry just after the module's code that lists the module-id of the "AppSpecific.ts" file) Note that while changing the bundling seems to have resolved the issue, it's not 100% clear if it's due to the experimental bundler having the bug fixed, or if instead it just caused a clearing of the build-cache or something. (since the issue only came up after a recompile earlier) GitHub comment where I found the (for now at least) solution: parcel-bundler/parcel#5683 (comment)
Guys The Solution is very Easy Delete the dist and .parcel folder and build the product again |
I understand this might work for your case, but when you're bundling and shipping software on a CI pipeline and you can't rely on the bundle being consistent and correct then it's a problem. |
Deleting and rebuilding feels like rebooting Windows lol I ran into this after following this Chart JS tutorial - When I ran into weird npm segment fault issues I upgraded node from 20 to 22, then I ran into a Cannot find module error, deleting the folders and rebuilding fixed the issue. |
I'm getting the same or a possibly related error, despite hearing repeatedly that it's been fixed.
I’m on 2.0.0, but the bug appears in 2.0.0-beta.3.1 and 2.12.0 as well. I tried |
I can reproduce this error consistently. I've yet to be able to distill it down to a simple reproduction. In my case, I'm unable to use code splitting- eg |
what i can think of is that parcle is not able to override the previous changes |
Definitely would love to see this get fixed. Every single time I import another module in a file, I get the "cannot find module" error and I have to kill the process and restart. Thankfully builds are lightning fast, but this is nevertheless a frustration because it happens every time and seems like a bug that undermines the core competency of this tool. |
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:
Run:
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:
To cause the behaviour (sometimes):
(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: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 inparcel@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 deletenode_modules
and runnpm 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:
a4cf3e9...f89e5ef
🔦 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 to2.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
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).)v15.4.0
6.14.11
The text was updated successfully, but these errors were encountered: