Error message: NestJS encountered a problem with Neovim due to an import prefix missing and the inability to load a local module

This issue can be frustrating as it doesn't affect the functionality of the program. However, upon opening a new or existing NestJS application, all imports are highlighted as errors. For instance, in 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 do not appear in VSCode or WebStorm. Upon researching, I found that these errors are typically associated with Deno/Python. Although I do not have Deno installed, I do have python2 and python3 for Neovim.

When running the application, everything operates smoothly without any errors. Interestingly, I do not encounter this issue when using Express or Koa, regardless of whether I'm using typescript. This particular problem seems to be unique to NestJS.

Answer №1

To manually configure linters in .vimrc, you can exclude the 'deno' linter for typescript by setting it up like this:

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

For detailed instructions, refer to: https://github.com/dense-analysis/ale#faq-disable-linters

:ALEInfo provides the following information:

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

Answer №2

It appears that the computer I was working on did have Deno installed, but there was a conflict during processing. I will need to figure out how to configure this with NeoVim. I discovered this issue by using the command :ALEDetail and received the following additional information:

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

This mistake is my own.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a nested type using template literal syntax

Given a two-level nested type with specific properties: export type SomeNested = { someProp: { someChild: string someOtherChild: string } someOtherProp: { someMoreChildren: string whatever: string else: string } } I am looking ...

Optimal Approaches for Conditional Rendering When Button Click is Involved in Combined Server and Client Components in Next.js 14

I'm currently working on a project using Next.js 14 and I've encountered an issue with implementing conditional rendering. In my setup, I have a server component that encompasses both server and client child components. Specifically, one of the c ...

Observable not defined in facade pattern with RxJS

(After taking Gunnar's advice, I'm updating my question) @Gunnar.B Tool for integrating with API @Injectable({ providedIn: 'root' }) export class ConsolidatedAPI { constructor(private http: HttpClient) { } getInvestments(search?: ...

What is the result of using `X ? A : B` in typescript?

type TestAny = any extends 'a' ? 1 : 2 // => 1 | 2 why??? how to interpret? type TestUnknown = unknown extends 'a' ? 1 : 2 // => 2 type TestStringA = 'a' extends 'a' ? 1 : 2 // => 1 type SomeUnion = ' ...

Unable to set intricate information to array variable in Angular 6

I have successfully implemented a method for retrieving data from an HTTP request, and it is functioning well, returning a complex list of data. https://i.sstatic.net/Hxpz2.png However, my concern arises when I try to assign the returned list to a variab ...

What steps can I take to have TypeScript limit the type of an array based on filter inference?

Here's a handy function that always returns an array of strings: (arr: (string | undefined)[]): string[] => arr.filter(item => item !== undefined); Check it out here However, TypeScript may not compile this code as expected due to its inferenc ...

JavaScript: Navigating function passing between multiple React components

I'm currently working on a React Native application utilizing TypeScript. In my project, there is a component named EmotionsRater that can accept two types: either Emotion or Need. It should also be able to receive a function of type rateNeed or rate ...

Similar to `util.inspect` in Node.js, Deno also has a function

Is there a utility function in Deno that can stringify an Object or primitive similar to Node.js util.inspect? For instance, if I have a JSON object in Node.js and want to display its contents: > m = {k1:'v1', k2:'v2'} { k1: ' ...

ReadOnly types in Inheritance

Currently, I am working on creating an unchangeable, nested data structure that also incorporates inheritance. To achieve this, I am using the Readonly generic type. In order to create different types within this structure, one of these Readonly types need ...

What is the process of displaying events from components within ng2 submodules?

My dilemma involves two components with straightforward output events and handlers. I am attempting to pass a value from a child submodule to a component within my app.module. Here is the snippet of code from my app.component.ts: @Component({ selector: ...

Issues arising with code splitting using React HashRouter in a project utilizing Typescript, React 17, and Webpack 5

Encountered build issues while setting up a new project with additional dependencies. package.json: { "name": "my-files", "version": "1.0.0", "description": "App", "main": " ...

Having trouble with data types error in TypeScript while using Next.js?

I am encountering an issue with identifying the data type of the URL that I will be fetching from a REST API. To address this, I have developed a custom hook for usability in my project where I am using Next.js along with TypeScript. Below is the code sni ...

Ideal method of re-entering ngZone following an EventEmitter event

There is a specific component that wraps around a library, and to prevent the chaos of change detection caused by event listeners in this library, the library is kept outside the Angular zone: @Component({ ... }) export class TestComponent { @Output() ...

What is the best way to combine two calls into a single condition check in React using Typescript?

Does anyone have suggestions on how to tackle this issue? I'm encountering difficulty as it is contained within a tag, which means it adheres to specific rules that I am unfamiliar with. The task involves generating a graph, and when the expandGraph v ...

Handling errors in nested asynchronous functions in an express.js environment

I am currently developing a microservice that sends messages to users for phone number verification. My focus is on the part of the microservice where sending a message with the correct verification code will trigger the addition of the user's phone n ...

Is it possible to retrieve and utilize multiple Enum values in Typescript?

Combine enum values to retrieve corresponding enum strings. Consider the following scenario: enum EnumDays { NONE = 0, SUN = 1, MON = 2, TUE = 4, WED = 8, THU = 16, FRI = 32, SAT = 64, ALL = 127 } If I pass a value o ...

Tip Sheet: Combining Elements from an Array of Objects into a Single Array

When I invoke the function getAllUsers() { return this.http.get(this.url); } using: this.UserService.getAllUsers().subscribe(res => { console.log(res); }) The result is: [{id:1, name:'anna'}, {id:2, name:'john'}, {id:3, name ...

In TypeScript, what is the return Type of sequelize.define()?

After hearing great things about TypeScript and its benefits of static typing, I decided to give it a try. I wanted to test it out by creating a simple web API with sequelize, but I'm struggling to understand the types returned from sequelize. Here ar ...

Transferring data types to a component and then sending it to a factory

I have been grappling with creating a factory method using Angular 2 and TypeScript. However, my attempts have hit a roadblock as the TSC compiler keeps throwing an unexpected error: error TS1005: ',' expected. The issue arises when I try to pa ...

The Art of Dynamic Component Manipulation in Angular

The current official documentation only demonstrates how to dynamically alter components within an <ng-template> tag. https://angular.io/guide/dynamic-component-loader My goal is to have 3 components: header, section, and footer with the following s ...