nestjs - neovim [import-prefix-missing no-local: Unable to load a local module] error

Viewed 592

This is an annoying problem as it doesn't effect the running of the program but when opening up a fresh (or existing) NestJS application all imports are flagged as an error for example, if we look at the main.ts file there are two imports:

import { NestFactory } from '@nestjs/core' // <-- (1)
import { AppModule } from './app.module'   // <-- (2)

error 1:

import-prefix-missing: Relative import path "@nestjs/core" not prefixed with / or ./ or ../ from "file:///Users/me/Documents/hello-world/src/main.ts

error 2:

no-local: Unable to load a local module: "file:///Users/me/Documents/hello-world/src/app.module". Please check the file path.

these errors are not shown in VSCode or in WebStorm When googling these errors they are related to Deno/Python, I don't have Deno installed but python2 and python3 are installed for Neovim

when running the application there is no errors and runs just fine, but I don't get this error when using Express or Koa with or without typescript. This issue is only with NestJS.

2 Answers

The linters can be set manually in .vimrc. There the 'deno' linter can be left out for typescript:

".vimrc
...
let g:ale_linters = { 'typescript': ['eslint', 'tsserver', 'typecheck'] }

As described in here: https://github.com/dense-analysis/ale#faq-disable-linters

:ALEInfo then says:

 Current Filetype: typescript
Available Linters: ['deno', 'eslint', 'standard', 'tslint', 'tsserver', 'typecheck', 'xo']
  Enabled Linters: ['eslint', 'tsserver', 'typecheck']
  Ignored Linters: []

So it looks like the computer that I am using DID have Deno installed and was processing it and there was a conflict. So I will need to find a way how to configure this with NeoVim. I figured this out by running the command :ALEDetail and provided additional information from where:

[deno] : mport-prefix-missing: Relative import path "@nestjs/core" not prefixed with / or ./ or ../ from "file:///Users/me/Documents/hello-world/src/main.ts

my fault

Related