E
E
Evgeny Zhurov2021-09-21 18:19:45
typescript
Evgeny Zhurov, 2021-09-21 18:19:45

Why does the "This dependency was not found" error occur?

Until some time, the project started normally, but one fine day (from scratch, i.e. no changes were made to the project and node_modules) when I ran the npm run dev command, this story popped up:

6149f6536f9e2318566996.jpeg

In the .nuxt/middleware itself .js, when built, the following entry is generated:

const middleware = {}
middleware['admin-auth'] = require('..\\client\\middleware\\admin-auth.ts')
middleware['admin-auth'] = middleware['admin-auth'].default || middleware['admin-auth']
export default middleware


The admin-auth.ts file absolutely lies on the path you are looking for: /client/middleware/admin-auth.ts

Its contents are:

import { Middleware } from '@nuxt/types'

const authMiddleware: Middleware = ({ store, redirect }): void => {
  if (!store.getters['auth/isAuthenticated']) {
    return redirect('/admin/login?message=login')
  }
}

export default authMiddleware


tsconfig looks like this:
{
  "compilerOptions": {
    "target": "es2019",
    "module": "commonjs",
    "lib": ["DOM", "DOM.Iterable", "es2020"],
    "sourceMap": true,
    "rootDir": "./",
    "removeComments": true,
    "noEmitOnError": false,
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noUnusedLocals": true,
    "noUncheckedIndexedAccess": false,
    "noPropertyAccessFromIndexSignature": false,
    "baseUrl": ".",
    "paths": {
      "~/*": ["./*"],
      "@/*": ["./*"]
    },
    "types": [
      "@types/node",
      "@nuxt/types",
      "@nuxtjs/axios",
      "buefy/types"
    ],
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}


What is this joke, and how to unsee it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question