11

Well in StackBlitz says "Can't find package: src ". I've read the questions from here and I've been trying the next things:

Can't find packages in stackblitz, even though it is present in npm website. How to install then?

How to downgrade the dependencies for npm packages in StackBlitz?

They doesn't work in my case cos when i type "src" says "dependencies installed" but it comes "Can't find..." again. I tried to delete and reinstall too. Also i tried to change absolute paths to relative.

"Using absolute paths for Typescript import statements causes project to give an error. It works fine in VS Code locally, but not on Stackblitz." (from google).

So I think its not a duplicate question

https://stackblitz.com/github/NachoBFL/ScientificApp?file=src%2Fapp%2Fapp-routing.module.ts

Nacho
  • 301
  • 4
  • 12

5 Answers5

7

The problem for me was that when I was coding, I used Stackblitz's autoimport, and it imported the library slightly wrong. In my case it did

import { TheClass } from "@theauthor/libname/lib";

instead of just

import { TheClass } from "@theauthor/libname"; 
CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
6

Hey I had the same problem when i was importing from github. The problem turned out to be... my IDE :) please make sure you do not have any import paths that start with "/src/app" and replace it with relative paths instead. Then one by one you will fix it and your Stackblitz will work.

ortho
  • 69
  • 1
  • 2
1

This issue is address here : https://github.com/stackblitz/core/issues/738 - solved, having the same problem with me and it resolved i will update you with all the details.

I have the same issue and i use this : i use this reference and modify it in my case:

Right: relative path import { environment } from '../environments/environment';

Wrong: import { environment } from 'src/environments/environment';

Amit kumar
  • 457
  • 6
  • 14
0

I had the same issue with @angular/material. The problem was that I was importing the modules the wrong way

import { MatIconModule } from '@angular/material/icon/public-api';

instead of

import { MatIconModule } from '@angular/material/icon';
user08
  • 695
  • 3
  • 8
  • 25
-1

I have the same problem in StackBlitz. You need to change all imports in ts files by replacing the prefix of paths src/app/ by ../ .

For example:

Wrong (absolute imports):

import { Employee } from 'src/app/models/employee.model';

Right (relative imports):

import { Employee } from '../models/employee.model';
colidyre
  • 4,170
  • 12
  • 37
  • 53
  • What you are calling absolute import is not absolute. In node module resolution, it's going to look for a `node_modules/src` – Ruan Mendes Nov 16 '21 at 21:25