Issue
I migrated my project from Angular 11 to Angular 12. I got errors using the ng update. So I took the raw way of doing it.
I created a fresh new Angular 12 project, added the dependencies all over again, and then replaced the src folder. The Angular 11 project had the default values in the config files. So I thought I can just use the defaults of Angular 12.
But again, I find the build logs flooded with error TS2307 for local filed.
I can see the file is present in the folder. But I still get this error
Error: src/app/components/open-orders/open-orders.component.ts:2:23 - error TS2307: Cannot find module 'src/app/data/Order' or its corresponding type declarations.
tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"module": "es2020",
"lib": [
"es2018",
"dom"
]
}
}
This is the open-orders.component.ts
import { Component, OnInit } from '@angular/core';
import { Order } from 'src/app/data/Order';
import { CloudService } from 'src/app/services/cloud.service';
I get the same error for the two local imports
Getting the same error when I use relative paths
import { Component, OnInit } from '@angular/core';
import { Order } from '../../data/Order';
import { CloudService } from '../../services/cloud.service';
I searched the net and tried the various tweaks (in tsconfig.json and angular.json) to get over the TS2307, but none of them seem to work.
Is this related to Angular 12? Can you help me resolve this?
Solution
You get the error because it's searching for a module at src/app/data/Order
which is missing. go check your path and look if such a module exists.
Answered By - Davis Jahn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.