When I import the workaround functions to Main.js the program stops working. I cannot figure out why?
From what I remember, you have to import modules from salaryData.js to the workaroundExplorer file and import modules from that file to main.js.
Open the browserâs console and check the error messages: If it logs that a file canât be found, you probably have an error in your file path. If it logs that anything is undefined or null, you probably imported modules in the wrong file.
How do I open the browser console to check the errors? Wouldâve been very helpful when I started the project lol. I was like I canât check errors and there is no video!
I know. Once you took the wrong turn in this project, you can get lost completely.
I think the development tools are preinstalled on almost all browsers now. So right click on any element in your project. Iâm not 100% sure which english term will appear: It must be something like âinspectâ. If you click that, it opens the dev toolbar with the console.
workAroundModule.js
import {getDataByRole, getDataByCompany} from â./modules./salaryData.jsâ;
import salaryData from â./modules./salaryData.jsâ
This is where the problem was. File path was incorrect. I changed it to â./salaryData.jsâ and everything is working now. Thank you for your help! The inspect window showed the console errors and eventually led me to this solution.
I still feel the correct file path is â./modules/salaryData.jsâ because salary.js is in the modules folder but for some reason the program wonât run with that file path.
So you found the issue, nice job!
The files workAroundModule.js and salaryData.js are in the same directory. If you import modules to workAroundModule.js from salaryData.js and the path is ./modules./salaryData.js
the program will look for the folder /modules in the very same folder.
I went through this multiple times today (not restarting, just checking every hint) and around step 6 it was working but displaying $0. Then i continued on and it went back to not displaying anything. In my import calls in main.js to the two files is â./modules/filename.jsâ (filename just placeholder for the 2 files for brevity). I went through to step 9 and changed the = 0 to reflect the function calls as per the hint. Still nothing. Iâve triple checked my imports and exports per hints and not sure what went south.
I actually got it working except for the extra challenge. I did get the code to display but not the results after using the formatNumber.format(function_and_rest_of_code).
Soo annoying, when I import the utilities.js into main.js the website breaks and only displays âdetailsâ.
import {formatNumber} from './modules/utilities.js'
thatâs my import, exported it like this:
export {formatNumber};
anyone know why this is the case?
(everything works fine up to this point)
Cheers!
Andy
I am having the exact same problem. Can you give a hint as to where you found the fix? I have gone over this so many timesâŚ
Hello, @andy_b.
Try opening your browserâs console, and see what error messages are there.
Hello, @lynda9408018042.
If youâd like to post your relevant code, someone can try to help.
Link to the project for reference.
Iâm having issues with this lesson as well. I hit step 8 and the whole program breaks. I try;
import {getAverageSalaryByRole, getAverageSalaryByCompany, getSalaryAtCompany, getIndustryAverageSalary} from './modules/workAroundModule.js';
it doesnât work and then when I go to inspect the issue it tells me;
Loading module from âhttps://5e818b7f5ab142a68b73451fd630d89f.cc-propeller.cloud/modules/modules/salaryData.jsâ was blocked because of a disallowed MIME type (âtext/plainâ).
and I canât quite figure out what that means exactly. Iâve tried it in other browsers with the same issue. Disabled my ad blockers, still nothing.
I have found another solution for this.
When i simply add a line in main.js:
import { getRoles, getCompanies } from './modules/salaryData.js';
Chrome dev tools console tells:
Uncaught SyntaxError: Cannot use import statement outside a module
So I just simply edit the html script line:
<script type="module" src="main.js" defer></script>
and now itâs working fine. Hope it will help.
Iâm stuck on the same part, I had it working up until the last checkpoint. It was returning values just fine, then I added utilities.js and exported functions, imported in main.js and I get that same âdisallowed MIME type âtext/plainâ)â type error in the console. Im scratchin my head trin to figure it out. Iâve already added the âmoduleâ type to the html file, as per a previous checkpointâŚ
did you end up finding a fix for this? I did the same thing and now it gives this error in console:
Loading module from âhttps://7c1fa89909c44a2c952aae51ba46c3e9.cc-propeller.cloud/utilities.jsâ was blocked because of a disallowed MIME type (âtext/plainâ). 7c1fa89909c44a2c952aae51ba46c3e9.cc-propeller.cloud
Iâm re-checking filepaths againâŚgahhhhh
EDIT
It was the filepath lol whodathunkit?!?!
how do I open the browser console?
Press F12, usually.
Can you say what was the correct filepath?
Try this at the bottom of you utitlities.js file:
export default formatNumber;