I want to separate route directory, but i can't and get below error.
rror [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './cjs' is not defined by "exports" in /mnt/.../projects/.../nanoexpress/node_modules/nanoexpress/package.json
app.js
const nanoexpress = require('nanoexpress');
var indexRouter = require('./routes/index');
const app = nanoexpress();
const port = 3333;
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.use('/testy',indexRouter)
app.listen(port)
routers/inde.js
const nanoexpress = require('nanoexpress/cjs');
const Route = require('nanoexpress/cjs/Route');
const app = nanoexpress();
const testRoute = new Route();
testRoute.get('/route', async () => 'hello');
module.exports.testRoute = testRoute;
Check this out. you need to register the route instance first. Read more here: https://nanoexpress.js.org/routes/route
