Closed gybeasmz closed 2 years ago
All right, I´m getting "null" basically on all DOM "querySelectors". Even on new files with just a few lines of code :-(
This is a brand new index and script.
Another update, so quokka is basically showing this message for any method I use on DOM elements. (.innerHTML etc.)
Hey,
looks like the file that you run (src/js/comntroller.js
) is located in a folder that is different from where the index.html
file is located, so Quokka jsdom can't find it. You may use Quokka jsdom configuration to specify the path to the html file, and then it should work for you.
If the solution suggested above doesn't address the issue, please let us know.
Hi Artem, that will most likely solve my problem, hovewer would you please be so kind and looked at the following picture and told me how I can specify path to that HTML file? I read the instructions, tried a couple of paths like "../../index.html" but I just can´t do it. I´m new to programming. Pretty pretty please
Depending on your project type, it may not be possible to get Quokka to run the same way as it does in your browser. This is because Quokka runs your code in node.js
and expects your file (in your case controller.js
) to be the entry point of your application.
When you use a browser, the HTML is effectively the entry point for your page and then scripts are loaded and executed from there.
This means that when running Quokka, your HTML will simply define the structure of your page, and for the most part will rarely have any script tags. When using Quokka, you also can't interact with your HTML file (as you are probably already aware).
You can read a little bit about how quokka works to better understand these differences.
You can also refer to an example repo using Quokka with JSDOM/HTML here.
If you're trying to get Quokka to run with an existing application, you may run into some compatibility problems where what you're trying to do in node and JSDOM is not possible, or is not possible without some significant restructuring of your code. Unfortunately we can't help with this as it very much depends on your project, it's structure, and what the code is doing.
Hello, how can I get rid of this, please? I have JSDOM installed. I tried to put the script in the index.html in the head with "defer" and also to the very end of the body. Nothing helps.