-
-
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
"Error: Does not have node" when importing assets and using module/nomodule pattern #5985
Comments
Can you share a reproduction? |
Sorry, I cannot reproduce it in a new project :| There's something funky going on. Sometimes it even throws a v8 error…
|
Sometimes it builds (not sure what's the causality). But even then the app fails to work because of a runtime error:
|
Could this be because you upgraded Parcel? Maybe try deleting .parcel-cache |
Now I tried removing |
There's not much we can do without a reproduction... Maybe you can somehow remove all closed source code from that "empty project with antdesign and typescript" whlie still retaining the file structure? |
I managed to create a reproduction with just a single .tsx file: https://github.com/mmiszy/parcel-problem-reproduction Build with
Log:
|
Looks like it's a problem with fonts. If I remove @font-face declarations, the build works fine. @mischnic |
This is only a problem when module/nomodule pattern is used: <script nomodule src="./index.js"></script>
<script type="module" src="./index.js"></script> Removing either of the lines fixes it. |
I see this problem too. Getting sporadic
|
Is this still a problem? |
I just got it in a project using @parcel/css. Along with Don't know if it has to do with module/nomodule or @parcel/css. Will debug more later and try to make a reproduction. Error log
|
Think I encountered the issue by changing parcel version and not removing |
I am also seeing this problem, even after removing the cache.
Each time I run yarn build I get different "Does not have node" output, most often while building a woff2 or |
@jhillyerd parcel v1 is ancient, try upgrading to v2 |
It's running parcel 2.4.0, I think the first line is the yarn version. |
Sorry, I'm stupid |
Also seeing this problem just after upgrading to parcel 2.4.0 (using node 16.13.0) Have cleared parcel-cache, node_modules, and all temp files.
Some times re-running the build process mysteriously works (without any changes at all). |
Working on this one |
Still getting the same error
and my project is empty, just installed tailwind nothing else !! |
When I imported the @fontface with a less file, parcel reports the same error
|
I get this issue having upgraded to parcel v2.8.3 (it also occurs in v2.7.0). I have deleted I have no occurrence of $ yarn build
yarn run v1.19.0
warning package.json: No license field
$ parcel build --no-cache --log-level error && node ./buildTasks/sassTasks.js && yarn check-types
Error: Does not have node 2555
at AssetGraph._assertHasNodeId (/project/node_modules/@parcel/graph/lib/Graph.js:411:13)
at AssetGraph.getNodeIdsConnectedFrom (/project/node_modules/@parcel/graph/lib/Graph.js:113:10)
at visitChildren (/project/node_modules/@parcel/core/lib/requests/AssetGraphRequest.js:170:47)
at /project/node_modules/@parcel/core/lib/requests/AssetGraphRequest.js:165:67
error Command failed with exit code 1. In order to fix this I have had to downgrade to parcel v2.6.2, which also locks us on typescript FWIW I don't believe this issue is fixed. |
For your information, I was not entirely correct about the downgrade to v2.6.2 fixing the issue; locally it builds every time, but on Github actions it still fails. Given this I wonder if there is something else at play here. @mischnic I will try to make a minimal reproduction of the issue 👍 |
I've made a minimal version of my application that just imports the svg, uses the latest typescript and parcel and it all build fine. I'm going to play around over the next few weeks to see if I can work out which particular combination of factors results in this. |
@mischnic I have been able to identify that the build fails based on how much parcel is doing, but a minimal reproduction does not seem to be feasible. This was my process: At the root of my package src files is a barrel file of this pattern: import { MyThing } from "./folder/MyThing";
// many more imports
export {
// many exports
MyThing,
// many more exports
}; I experimented with removing all imports and exports, using various algorythms to re-add the import/export pairs. I noticed that the build became more and more unreliable after the 50 mark (I tried this 3 different times with the same outcome). I also tried leaving all imports but removing all the parameters in the export object (bar 1) and the build was again unreliable. Commenting out the imports made the build reliable again. I tried to make a minimal reproduction with a really simple component repeated 340 times in a barrel file, but parcel handles this pretty easily and outpts a transpiled js file of about the same size as my actual project. So I think the very concept of a simple reproduction here is not viable. 🤷 I'd be happy to try out any other debugging if you can recommend a way... |
OK @mischnic , I think that I now know what is causing my issue, but I can't claim to understand why. I believe that there are essentially 2 issues. The first issue only occurs when the output files are set to the configuration below. I spent some time trying to analyse which of my files were causing issues during build. I could safely build all my svg icons directly and most of my normal react components, but the components that imported svg icons seemed to intermittently cause the build to fail. This was very hard to debug due to the intermittent nature. I think there is genuinely a problem here, but I have been unable to reproduce the issue outside of this project. Issue 2 seems to be the root cause. It occurred to me that when I rolled back my parcel upgrade, that I was still experiencing the same problem, so I reviewed other changes I made at the same time and discovered that I had also changed the output to match the docs and reflect my actual output. This "source": [
"src/index.ts"
],
"main": "build/index.umd.cjs",
"module": "build/index.js",
"types": "build/types.d.ts",
"files": [
"build"
],
"exports": {
".": {
"import": "./build/index.js",
"require": "./build/index.umd.cjs"
}
}, When I reverted back to this, the build failures ceased, but it doesn't reflect my needs: "source": [
"src/index.ts"
],
"main": "build/index.umd.cjs",
"module": "build/index.js",
"browser": "build/index.js",
"types": "build/types.d.ts",
"targets": {
"main": false,
"module": false
},
"files": [
"build"
],
Equally, I can get this to work, but it doesn't output the ES module file, rather it outputs a file called "source": [
"src/index.ts"
],
"main": "build/index.umd.cjs",
"module": "build/index.js",
"types": "build/types.d.ts",
"targets": {
"main": false
},
"files": [
"build"
],
"exports": {
".": {
"import": "./build/index.js",
"require": "./build/index.umd.js"
}
}, Basically, it seems to need the I realise that there is not enough information to make a repro (and therefore debug), so I don't know how valuable this is from that point of view, but other people encountering this issue might look to see if they are trying to output more than one file at the same time... or try adding the |
To be clear, the issue is having any of the outputs using the same file "name" (the .umd and file type are not taken into account) |
I investigated this a bit more with @snowystinger. Our theory is that there is a race condition which can fail when you have the same CSS asset being loaded in multiple environments (e.g. node and browser, or main and module). We believe what's happening is that a CSS file is requested from two different environments simultaneously, e.g. two dependencies for the same file with different environments. We go to the CSS transformer, and this normalizes the environment to prevent duplicate assets from being created: parcel/packages/transformers/css/src/CSSTransformer.js Lines 27 to 35 in b2331a1
This means that the two transformation requests resolve to the same asset id. However, if one of them finishes first while the other one is still running, it could move on to the dependencies of that CSS file (e.g. an SVG). Then, when the second one comes back and resolves to the same asset, this will try to replace the child nodes of that asset with new dependencies. parcel/packages/core/core/src/AssetGraph.js Lines 530 to 533 in b2331a1
Finally, when the request for the dependency from the first transformation (e.g. SVG) comes back, the node is no longer there because it was replaced by the second instance and it blows up here:
I'm not exactly sure how to fix this yet, but thought I'd write down some notes. |
I ran into this issue ( @cipherlogs might this have been the same issue you were seeing? |
@mrcoles Yes it could be, I stopped using Parcel, I just use Vite now. |
@devongovett I have experienced this on multiple projects now. I can’t share a sample repo, yet, but here’s some info to try and help triangulate:
|
I fixed it for me by removing these from my @font-face {
font-family: "Open Sans";
src: url("./fonts/Open_Sans/OpenSans-Regular.ttf");
font-weight: 400;
font-style: normal;
}
@font-face {
font-family: "Open Sans";
src: url("./fonts/Open_Sans/OpenSans-SemiBold.ttf");
font-weight: 600;
font-style: bold;
}
@font-face {
font-family: "Open Sans";
src: url("./fonts/Open_Sans/OpenSans-Bold.ttf");
font-weight: 700;
font-style: normal;
} Parcel v2.8.3 |
hi there, i am getting this errror for the past two days. i tried to unistall cache ,and to install better version of parcel but i am still getting this error what should i do Error: Expected content key d887f3ca450c74ac to exist |
It's almost an empty project with antdesign and typescript.
Builds fine when
--no-scope-hoist
is used.error output
package.json
.babelrc
🤔 Expected Behavior
The project builds with scope hoisting.
😯 Current Behavior
Error.
🌍 Your Environment
The text was updated successfully, but these errors were encountered: