D
Deno

help

does not provide an export named... module import

CChilliSniff9/24/2022
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 ?
Jjavi9/24/2022
Can you show us the code? This works as intended
UUUnknown User9/25/2022
2 Messages Not Public
Sign In & Join Server To View
NNeTT9/25/2022
import() imports the default export under a default property
UUUnknown User9/25/2022
Message Not Public
Sign In & Join Server To View
CChilliSniff10/1/2022
i dont export with default export {mymod}
Nnayeemrmn10/1/2022
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
CChilliSniff10/1/2022
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
UUUnknown User10/2/2022
Message Not Public
Sign In & Join Server To View
CChilliSniff10/2/2022
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;
}
}

Looking for more? Join the community!