Angular project `can't find package: src` - Solved
See original GitHub issueFor anyone that runs into this issue.
Using absolute paths for Typescript import
statements causes project to give an error.
It works fine in VS Code locally, but not on Stackblitz.
Wrong: absolute importimport { Employee } from 'src/app/models/employee.model';
Right: relative imports import { Employee } from '../models/employee.model';
I’m new to Angular so I’m not sure what the best practices are.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:16
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Can't find package src in StackBlitz after installing dependencies
"Using absolute paths for Typescript import statements causes project to give an error. It works fine in VS Code locally, but not on...
Read more >Creating libraries - Angular
This page provides a conceptual overview of how to create and publish new libraries to extend Angular functionality. If you find that you...
Read more >cannot find module [Node npm Error Solved] - freeCodeCamp
To fix the error, you need to install the package that is absent in your project directory – npm install package-name or yarn...
Read more >Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >Cannot find module '@angular-devkit/build-angular ... - YouTube
... occurred: Cannot find module '@ angular -devkit/build- angular / package.json'The above exception while running an angular app can be handl.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No need to enable absolute paths in Angular, I think this is more of a Typescript / Javascript file import thing. Most Angular CLI commands & options only use relative paths.
ng g c /path/myComponent --my-option 'C:\documents\more\absolute\paths'
Argument for absolute paths
EmployeeComponent imports the ApiService
import { ApiService } from '../../../core/services/api.service';
import { ApiService } from 'src/app/core/services/api.service';
// Configure tsconfig.jsonProjects with deep directory structures benefit from absolute import paths. I see you’re already dealing with this in Issue #139, this issue might be duplicate.
but it doesn’t work me!!!