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
Import syntax error with express.Router() import #5532
Comments
One thing I made an oopsie here with is the
|
I am nearly positive even if you get this issue worked out you will just hit other issues. Express couples deeply to Node.js api's which are likely different enough to matter. Just don't want to provide an answer on the errors without pointing out you are likely in for a world of pain 🤣. Additionally I don't think it has been discussed yet, but we likely do not have any plans to support Bun, so YMMV on this effort even in the longer term. That said, it looks to me like something else is up with your code as I am not sure how the runtime difference could cause a typeof check to fail. And since that is the case, I am going to close this since we do not do technical support in here. If you can prove this is a bug of some sort in express please re-open this, but otherwise I would ask on Reddit or StackOverflow. |
I agree with Wes. I'll add this to give you some suggestion though. import { Router as viewRouter } from 'express'
viewRouter().get('/', (req, res) => {
res.render('index')
})
export default viewRouter
I would suggest the following instead for export default app => {
app.get('/', (req, res) => {
res.render('index')
})
} and in import express from 'express'
import viewRouter from './routes/viewRouter.js'
// other code
...
const app = express()
....
viewRouter(app) |
Thank you both, I appreciate the feedback :D Joey, this is an excellent alternative to what I was trying to do and even cleaner at that. I will have to take a gander at this when I'm in front of my editor again. Much appreciated. |
Need help figuring out why this would error.
I am using bun and not node for the runtime. I don't think that affects anything here. I am using express JS 5.0 BETA 1
I just feel there is a better way than actually doing (despite Node/Bun caching modules I still feel like this is redundant):
The text was updated successfully, but these errors were encountered: