-
-
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
Getting Cannot read property 'js' of null
#1158
Comments
Perhaps try removing the cache and rebuild? |
I tried that already. The problem is gone if I remove two entry points from two different files and put it back in once the HMR is running. I've login.html and register.html and I've to remove
from one of them and it works but I've to put it back to see CSS taking effect (once running). |
Yes it's a bug I've encountered too. In my case it happens when I use I have several guesses as to what might be causing it, the main one being that the bug might be caused by the quotes inside the Also if you make a change in the code and trigger the HMR then it removes the error, and the error will come back when you make a change to the scss file containing the background or in any file that imports it, basically whenever it's parsed again and generates new faulty js code. |
Not sure why, but in my case I added the |
Same problem here. Can a maintainer have a look ? |
Does this still occur on v1.8.1? |
Yep. |
I started getting this issue after combining my four separate bundles into one bundle with multiple entry points. I tried splitting it up into 1 bundle for my main app, and a separate bundle for the other 3 smaller apps and afterwards the error stopped occurring. I'm not sure what the significance of this change would be though. |
Is anyone still having this issue? |
It's stopped happening in my case. Not sure about the other ones though. |
@devongovett I had a similiar issue, but instead of Not sure if it's related, but it might help someone down the road. |
I'm having this issue currently. It started after adding a Rust/WASM module to one of my subtrees. My setup involves a "root" $ parcel build src/lab/{index.html,README.md} --public-url /
🚨 Cannot read property 'js' of null
at JSPackager.dedupeKey (/Users/matt/Sites/fartts/fartts/node_modules/parcel-bundler/src/packagers/JSPackager.js:110:40)
at JSPackager.addAsset (/Users/matt/Sites/fartts/fartts/node_modules/parcel-bundler/src/packagers/JSPackager.js:42:22)
at JSPackager.addAssetToBundle (/Users/matt/Sites/fartts/fartts/node_modules/parcel-bundler/src/packagers/JSPackager.js:145:16)
at JSPackager.writeBundleLoaders (/Users/matt/Sites/fartts/fartts/node_modules/parcel-bundler/src/packagers/JSPackager.js:161:18)
at JSPackager.end (/Users/matt/Sites/fartts/fartts/node_modules/parcel-bundler/src/packagers/JSPackager.js:221:20)
at Bundle._package (/Users/matt/Sites/fartts/fartts/node_modules/parcel-bundler/src/Bundle.js:199:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. I'm still digging around. Will report back if I find anything. |
Weird, but if I run |
Just my 2 cents worth... I have this issue when parcel is run from a directory other than the project directory (such as global). If it is installed in the project, and I run that version, then I have no issues. |
https://github.com/quasicomputational/parcel-1158 is a reproducer that's as small as I could get it. Removing any of the imports makes the symptom vanish, likewise removing any more of |
What was your intention/original code with importing html in JS (causing a circular dependency)? import "./lister.html"; |
In the actual code, it's actually importing the HTML asset as a URL reference so that it can be navigated to using my (admittedly hackish) plugin. But, as demonstrated by the reduced example, the plugin's not relevant to the bug at hand. Where is the circular dependency? The assets form a DAG, and Parcel happily worked on the actual code. (Well, until this bug bit me, but that happened after some apparently unrelated changes...) |
I've done a little bit of investigation into this and I've come out still confused, but I did manage to get a working build. There are at least two bugs going on here. First, the
But I don't know if this is the right thing or not; I have no idea when Second, observe the return value of the parcel/packages/core/parcel-bundler/src/assets/JSAsset.js Lines 191 to 197 in 636bb50
But look at how
And elsewhere it's also treated as an object (picking two arbitrary use sites): parcel/packages/core/parcel-bundler/src/Asset.js Lines 254 to 269 in 636bb50
parcel/packages/core/parcel-bundler/src/Bundler.js Lines 709 to 715 in 636bb50
This definitely doesn't seem right. As an experiment, I changed the return value This is the diff I wound up applying to Parcel to get it working. So, yeah. I don't understand Parcel's internals well enough to say whether these are proper fixes or not (very likely not). Hopefully, this is enough to go on for someone who does know them well enough to make a real fix. |
Sweet! I'll try that out as soon as I can and see if it fixes my issues. |
Don't get too excited. The build succeeds, but the bundles are coming out broken. I guess some internal invariant is getting broken somewhere and this issue's just one symptom of it... |
I have a similar issue that appeared out of the blue: I had a knee-jerk reaction that upgrading npm was the culprit, but after full uninstall and clean install with prior versions (node v11.14.0 & npm 6.9.0) the problem persists. I tried removing node_modules, clearing cache, and building previously working branches--no luck. Looking at JSPackager, it seems the problem is the first asset (id parcel/packages/core/parcel-bundler/src/packagers/JSPackager.js Lines 88 to 94 in c2760fd
I tried adding a return statement if asset.generated is empty object (as suggest in #1227), which made the error go away, but the client complained Anyone have a fix or workaround for this? |
I've found a workaround! At least for my case - I don't know about anyone else. The bug is something to do with how Parcel's traversing the dependency graph when one of the non-entry nodes is a HTML file that has scripts. There's almost certainly more to it than that, but explicitly lifting the HTML asset to be an entry makes the problem go away. Concretely, on the reproduction repo, If I invoke it as Hopefully this gives someone a clue about where the bug might be. |
Fixes the same error as reported [here](parcel-bundler/parcel#1158). Also ignores some TS warnings.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
Auto-closing is not good, a problem not resolved should not simply disappear. It still occurs to me, and removing the In my case, I'm using natural and it writes: var _ = require('underscore')._; This is just as specified in the underscore.js documentation (of Hope this can be of help. |
Removing the Hopefully |
Still experiencing this issue |
I get the error ("parcel-bundler": "^1.12.4"), if a have a inline style in html :(
solution: |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
Cleaning the |
Choose one: is this a 🐛 bug report or 🙋 feature request?
🐛
Getting
Cannot read property 'js' of null
on initial run withnpm start
but the error goes aways if I make change to any file. But when trying to create a production build withnpm run build
the same error shows up and fails the build.🎛 Configuration (.babelrc, package.json, cli command)
🤔 Expected Behavior
The build process should complete without any error.
😯 Current Behavior
Build fails with the following error:
💁 Possible Solution
🔦 Context
The error happened after I added a new html file and linked it in my index.html file. See the code sample bellow. If I remove index.js from other.html the error goes away but I can't do that since index.js contains the scss file import which is required for the styling of the other.html page.
💻 Code Sample
index.html
other.html
index.js
🌍 Your Environment
The text was updated successfully, but these errors were encountered: