ChilliSniff
ChilliSniff3y ago

does not provide an export named... module import

does anybody know whats going on, when i reload my page only sometimes i get this message :
The requested module './mymod.module.js' does not provide an export named 'mymod'
The requested module './mymod.module.js' does not provide an export named 'mymod'
when i import like this
import {mymod} from "./mymod.module.js"
import {mymod} from "./mymod.module.js"
but when i import like this
var mymod = (await import("./mymod.module.js")).mymod
var mymod = (await import("./mymod.module.js")).mymod
then it is working what is going on ?
9 Replies
javi
javi3y ago
Can you show us the code? This works as intended
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
NeTT
NeTT3y ago
import() imports the default export under a default property
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
ChilliSniff
ChilliSniffOP3y ago
i dont export with default export {mymod}
nayeemrmn
nayeemrmn3y ago
That second example is not working, you have the parentheses in the wrong place so mymod is set to undefined. I think it would be undefined even with proper parentheses though. Please show mymod.module.js
ChilliSniff
ChilliSniffOP3y ago
Uncaught SyntaxError: The requested module './mymod.module.js' does not provide an export named 'mymod' mymod.js
var mymod = {
test: true
}

export {mymod}
var mymod = {
test: true
}

export {mymod}
the weird thing is that sometimes it works, sometimes it does not work when i dont await the import... when i await the import it works every time i think the problem lies within my webserver sometimes i get the wrong response from the reuqest to mymod.module.js
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
ChilliSniff
ChilliSniffOP3y ago
thanks it cannot work because my webserver respond with the wrong file only sometimes im currently switching from the import { serveTls } from "https://deno.land/std@0.147.0/http/server.ts?s=serveTls"; to the native? Deno.listenTls , maybe this will solve my problem ok im quite sure there was some async fuckery going on, now it is working , i did it like this
var o_server = Deno.listenTls(
{
certFile: o_self.o_config.o_ssl.s_path_certificate_file,
keyFile: o_self.o_config.o_ssl.s_path_key_file,
port: o_self.o_config.o_encrypted.n_port,
hostname: o_self.o_config.o_encrypted.s_host,
}
);
while (true) {
try {
const o_connection = await o_server.accept();
// ... handle the o_connectionection ...
// console.log(o_connection)
const o_http_connection = Deno.serveHttp(o_connection);
while (true) {

try {
const o_request_event = await o_http_connection.nextRequest();
// ... handle o_request_event ...
// console.log(`${this.s_file_name}: o_request_event: ${o_request_event}`)
await o_http_request_handler.f_http_request_handler(
o_http_connection,
o_request_event,
o_self
)

} catch (err) {
console.log(`${this.s_file_name}: connection has finished or error: ${err}`)
console.log(`${err.stack}`)
// the connection has finished
break;
}
}

} catch (err) {
console.log(`${this.s_file_name}: listener has closed: or error: ${err}`)
console.log(`${err.stack}`)

// The listener has closed
break;
}
}
var o_server = Deno.listenTls(
{
certFile: o_self.o_config.o_ssl.s_path_certificate_file,
keyFile: o_self.o_config.o_ssl.s_path_key_file,
port: o_self.o_config.o_encrypted.n_port,
hostname: o_self.o_config.o_encrypted.s_host,
}
);
while (true) {
try {
const o_connection = await o_server.accept();
// ... handle the o_connectionection ...
// console.log(o_connection)
const o_http_connection = Deno.serveHttp(o_connection);
while (true) {

try {
const o_request_event = await o_http_connection.nextRequest();
// ... handle o_request_event ...
// console.log(`${this.s_file_name}: o_request_event: ${o_request_event}`)
await o_http_request_handler.f_http_request_handler(
o_http_connection,
o_request_event,
o_self
)

} catch (err) {
console.log(`${this.s_file_name}: connection has finished or error: ${err}`)
console.log(`${err.stack}`)
// the connection has finished
break;
}
}

} catch (err) {
console.log(`${this.s_file_name}: listener has closed: or error: ${err}`)
console.log(`${err.stack}`)

// The listener has closed
break;
}
}