router-module
router-module copied to clipboard
`Cannot read properties of undefined (reading 'options')` on add @nuxtjs/router to Nuxt 3 project
I got error
ERROR Cannot start nuxt: Cannot read properties of undefined (reading 'options') 13:12:10 at nuxtModule (node_modules@nuxtjs\router\dist\module.js:21:16)
once tried to add the @nuxtjs/router module to my Nuxt3 project. The log refers to:
const nuxtModule = function(moduleOptions) {
const DEFAULTS = {
path: this.options.srcDir,
fileName: "router.js",
keepDefaultRouter: false
};
// ...
where this is undefined.
Is it because some TypeScript or nuxt configuration?
All append the listings and the whole project.
Nuxt configuration
export default defineNuxtConfig({
buildDir: "03-LocalDevelopmentBuild/ClientAndRenderingServer",
dir: {
assets: "SharedAssets",
layouts: "Layouts",
pages: "Pages",
plugins: "NuxtPlugins"
},
srcDir: "01-Source/Implementation/Elements/ClientAndRenderingServer",
modules: [
[
"@nuxtjs/router",
{
path: "01-Source/Implementation/Elements/ClientAndRenderingServer/Routing",
fileName: "router.ts"
}
]
]
});
Typescript configuration
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"strict": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": false, /* Actual for Vue3; see https://github.com/vuejs/vue-next/issues/4668 */
"experimentalDecorators": true,
"baseUrl": "./01-Source"
},
"ts-node": {
"require": [
"tsconfig-paths/register"
]
}
}
You should be able to remove this package for nuxt 3 https://nuxt.com/docs/getting-started/routing